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
```bash
$ google-chrome --headless --remote-debugging-port=9222 --disable-gpu "about:blank"
```
To disable image loading, add `--blink-settings=imagesEnabled=false` argument:
```bash
$ google-chrome --headless --remote-debugging-port=9222 --disable-gpu --blink-settings=imagesEnabled=false "about:blank"
```
## Install Prerender
```bash
$ pip install -U prerender
```
## Start Prerender
As standalone application:
```bash
$ prerender
```
To run it under gunicorn:
```bash
$ 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:
```bash
$ # 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.
| ENV | default value | description |
|----------------------------|------------------|-------------------------------------------------------------------------------------------------|
| HOST | 0.0.0.0 | Prerender listen host |
| PORT | 8000 | Prerender listen port |
| DEBUG | false | Toggle debug mode |
| PRERENDER_TIMEOUT | 30 | renderring timeout |
| PAGE_DONE_CHECK_TIMEOUT | 200 | Number of milliseconds between the interval of checking whether the page is done loading or not |
| CONCURRENCY | 2 * CPU count | Chrome pages count |
| MAX_ITERATIONS | 200 | Restart Chrome page after rendering this many pages |
| CHROME_HOST | localhost | Chrome remote debugging host |
| CHROME_PORT | 9222 | Chrome remote debugging port |
| USER_AGENT | | Chrome User Agent |
| BLOCK_FONTS | 1 | Block web fonts loading, set to 0 to allow fonts loading |
| ALLOWED_DOMAINS | | Domains allowed for renderring, comma seperated |
| CACHE_BACKEND | dummy | Cache backend, `dummy`, `disk`, `s3` |
| CACHE_LIVE_TIME | 3600 | Disk cache live seconds |
| CACHE_ROOT_DIR | /tmp/prerender | Disk cache root directory |
| S3_SERVER | s3.amazonaws.com | S3 server address |
| S3_ACCESS_KEY | | S3 access key |
| S3_SECRET_KEY | | S3 secret key |
| S3_REGION | | S3 region |
| S3_BUCKET | prerender | S3 bucket name |
| SENTRY_DSN | | Sentry DSN, for exception monitoring |
| ENABLE_CIRCUIT_BREAKER | false | enable circuit breaker |
| CIRCUIT_BREAKER_FAIL_MAX | 5 | maximum failures per browser/bot before circuit breaker open |
| CIRCUIT_BREAKER_RESET_TIMEOUT | 60 | circuit breaker reset timeout in seconds |
## Configure client
Please view the original NodeJs version [prerender](https://github.com/prerender/prerender#official-middleware) README.
## License
MIT
Metadata
Release files for prerender 0.10.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| prerender-0.10.0.tar.gz | 14.1 kB | Without provenance | Details for prerender-0.10.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| prerender-0.10.0-py3-none-any.whl | Python 3 | none | any | Details for prerender-0.10.0-py3-none-any.whl |
Total release size: 31.8 kB
Release files / prerender-0.10.0.tar.gz
| Download URL | prerender-0.10.0.tar.gz |
|---|---|
| Size | 14.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
13ae206f0f96604433d7619c143206895350a61e94bcd74bf6b5534ac4c3b1d3
|
|
BLAKE2b-256 checksum How to use checksums |
8d31e4486f2b4ada4aaa784ad9341c4b1e5951c85ff18f0b9ce37db78f58576b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / prerender-0.10.0-py3-none-any.whl
| Download URL | prerender-0.10.0-py3-none-any.whl |
|---|---|
| Size | 17.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e1680afa0c8a05eac8de9db5713a08b7d7e7d93b1951075c1658c53d003c485f
|
|
BLAKE2b-256 checksum How to use checksums |
bc1ee3059bf0531ace5ba00e58eaf1ac1fa68734c90ca5d6172de6340571d45a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for prerender 0.10.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.