Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cheeaun/puppetron
Puppeteer (Headless Chrome Node API)-based rendering solution.
https://github.com/cheeaun/puppetron
chrome chromium headless pdf prerender puppeteer screenshot
Last synced: 29 days ago
JSON representation
Puppeteer (Headless Chrome Node API)-based rendering solution.
- Host: GitHub
- URL: https://github.com/cheeaun/puppetron
- Owner: cheeaun
- Created: 2017-08-22T08:48:50.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2022-06-17T01:45:48.000Z (over 2 years ago)
- Last Synced: 2024-09-30T15:22:09.320Z (about 1 month ago)
- Topics: chrome, chromium, headless, pdf, prerender, puppeteer, screenshot
- Language: JavaScript
- Homepage: https://puppetron.now.sh/
- Size: 182 KB
- Stars: 527
- Watchers: 16
- Forks: 91
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-puppeteer - Puppetron - Demo site that shows how to use Puppeteer and Headless Chrome to render pages. Inspired by [GoogleChrome/rendertron](https://github.com/GoogleChrome/rendertron). (Rendering and web scraping)
- awesome-list - puppetron - based rendering solution. | cheeaun | 438 | (JavaScript)
- awesome-puppeteer-zh - Puppetron - 演示网站,演示如何使用Puppeteer和`Headless Chrome`渲染页面. 灵感来自[GoogleChrome/rendertron](https://github.com/GoogleChrome/rendertron). (渲染和网页抓取 / 贡献)
README
#
> [Puppeteer](https://github.com/puppeteer/puppeteer) (Headless Chrome Node API)-based rendering solution.
Videos & Tweets:
- Demo
- `clipSelector` demo
- CJK fonts support
- Emoji support**⚠️⚠️⚠️ NOTE:** Starting version 2.0, CJK and emoji support is gone.
## 🚧🚧🚧 PLEASE READ THIS 🚧🚧🚧
**Do NOT use this for production use-cases.**
This is just a demo site of what cool things that `Puppeteer` can do. Under any circumstances, this site may be down any time or be heavily rate-limited to prevent abuse.
Please check out what [Puppeteer](https://github.com/GoogleChrome/puppeteer) can do for your own use case and host on your own servers.
## API
The API can perform 3 actions:
- [Screenshot](#screenshot) - take a screenshot of the web page
- [Render](#render) - render and serialize a HTML copy of the web page
- [PDF](#pdf) - generate a PDF of the web page**`URL`** - the URL with encoded `pathname`, `search` and `hash`.
Global parameters:
- `width` - width of viewport/screenshot (default: `1024`)
- `height` - height of viewport/screenshot (default: `768`)### Screenshot
```
/screenshot/{URL}
...or
/{URL}
```Parameters:
- `thumbWidth` - width of thumbnail, respecting aspect ratio (no default, has to be smaller than `width`)
- `fullPage` - takes a screenshot of the full scrollable page (default: `false`). If the page is too long, it may time out.
- `clipSelector` - CSS selector of element to be clipped (no default). E.g.: `.weather-forecast`.### Render
```
/render/{URL}
```Notes:
- `script` tags except `JSON-LD` will be removed
- `link[rel=import]` tags will be removed
- HTML comments will be removed
- `base` tag will be added for loading relative resources
- Elements with absolute paths like `src="/xxx"` or `href="/xxx"` will be prepended with the origin URL.Parameters: _None_
```
/pdf/{URL}
```Parameters:
- `format`: Paper format that [Puppeteer supports](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pagepdfoptions). E.g.: `Letter`, `Legal`, `A4`, etc. (default: `Letter`)
- `pageRanges`: Paper ranges to print. E.g., `1-5`, `8`, `11-13` (default all pages)## Development
### Requirements
- [Node.js](https://nodejs.org/en/)
- [Vercel](https://vercel.com/download)#### Steps
1. `npm i`
2. `npm start`
3. Load `localhost:3000`## Credits
Block list from [Prerender](https://github.com/prerender/prerender/blob/master/lib/resources/blocked-resources.json).
For version 1.0, this uses [`cheeaun/puppeteer`](https://hub.docker.com/r/cheeaun/puppeteer/) Docker image.
For version 2.0, this uses some parts from [Zeit's now-examples: misc-screenshot](https://github.com/zeit/now-examples/blob/master/misc-screenshot/Dockerfile).
Inspired by [`zenato/puppeteer`](<(https://hub.docker.com/r/zenato/puppeteer/)>), [`puppeteer-renderer`](https://github.com/zenato/puppeteer-renderer) and [Rendertron](https://render-tron.appspot.com/).