[ScreenshotKit] (Headless Chrome Node API)-based rendering solution.
The API can perform 3 actions:
- Screenshot - take a screenshot of the web page
- Render - render and serialize a HTML copy of the web page
- 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/{URL}
...or
/{URL}
Parameters:
thumbWidth
- width of thumbnail, respecting aspect ratio (no default, has to be smaller thanwidth
)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/{URL}
Notes:
script
tags exceptJSON-LD
will be removedlink[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"
orhref="/xxx"
will be prepended with the origin URL.
Parameters: None
/pdf/{URL}
Parameters:
format
: Paper format that Puppeteer supports. E.g.:Letter
,Legal
,A4
, etc. (default:Letter
)pageRanges
: Paper ranges to print. E.g.,1-5
,8
,11-13
(default all pages)
- Node.js
- Docker
For local Chromium install:
npm install
npm start
- Load
localhost:3000
For Docker-based install:
docker build . -t puppet
docker run -p 8080:3000 puppet
- Load
localhost:8080
Mitchbux