Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

prerender

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prerender

Render JavaScript-rendered page as HTML using headless Chrome

  • 0.10.0
  • PyPI
  • Socket score

Maintainers
1

prerender

Render JavaScript-rendered page as HTML/PDF/mhtml/png/jpeg using headless Chrome

Install Chrome

Headless mode is supported in Chrome stable 59+ and unstable/dev channel, you should be able to install it via:

https://www.google.com/chrome/browser/beta.html?platform=linux

Start Chrome Headless

$ google-chrome --headless --remote-debugging-port=9222 --disable-gpu "about:blank"

To disable image loading, add --blink-settings=imagesEnabled=false argument:

$ google-chrome --headless --remote-debugging-port=9222 --disable-gpu --blink-settings=imagesEnabled=false "about:blank"

Install Prerender

$ pip install -U prerender

Start Prerender

As standalone application:

$ prerender

To run it under gunicorn:

$ gunicorn --bind 0.0.0.0:3000 --worker-class sanic.worker.GunicornWorker prerender.app:app

How does it work

Say you deployed Prerender under http://prerender.example.com:8000, to render http://example.com you can do:

$ # render HTML
$ curl http://prerender.example.com:8000/http://example.com
$ curl http://prerender.example.com:8000/html/http://example.com
$ # render mhtml
$ curl http://prerender.example.com:8000/mhtml/http://example.com
$ # render PDF
$ curl http://prerender.example.com:8000/pdf/http://example.com
$ # render png
$ curl http://prerender.example.com:8000/png/http://example.com
$ # render jpeg
$ curl http://prerender.example.com:8000/jpeg/http://example.com

Configuration

Settings are mostly configured by environment variables.

ENVdefault valuedescription
HOST0.0.0.0Prerender listen host
PORT8000Prerender listen port
DEBUGfalseToggle debug mode
PRERENDER_TIMEOUT30renderring timeout
PAGE_DONE_CHECK_TIMEOUT200Number of milliseconds between the interval of checking whether the page is done loading or not
CONCURRENCY2 * CPU countChrome pages count
MAX_ITERATIONS200Restart Chrome page after rendering this many pages
CHROME_HOSTlocalhostChrome remote debugging host
CHROME_PORT9222Chrome remote debugging port
USER_AGENTChrome User Agent
BLOCK_FONTS1Block web fonts loading, set to 0 to allow fonts loading
ALLOWED_DOMAINSDomains allowed for renderring, comma seperated
CACHE_BACKENDdummyCache backend, dummy, disk, s3
CACHE_LIVE_TIME3600Disk cache live seconds
CACHE_ROOT_DIR/tmp/prerenderDisk cache root directory
S3_SERVERs3.amazonaws.comS3 server address
S3_ACCESS_KEYS3 access key
S3_SECRET_KEYS3 secret key
S3_REGIONS3 region
S3_BUCKETprerenderS3 bucket name
SENTRY_DSNSentry DSN, for exception monitoring
ENABLE_CIRCUIT_BREAKERfalseenable circuit breaker
CIRCUIT_BREAKER_FAIL_MAX5maximum failures per browser/bot before circuit breaker open
CIRCUIT_BREAKER_RESET_TIMEOUT60circuit breaker reset timeout in seconds

Configure client

Please view the original NodeJs version prerender README.

License

MIT

Keywords

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc