Name: screenshot
Owner: Pressly Inc.
Description: Screenshot as a service: GoogleChrome/puppeteer Node.js REST API server + Golang client
Created: 2017-12-04 15:54:09.0
Updated: 2018-04-20 02:00:55.0
Pushed: 2017-12-18 02:34:28.0
Size: 2140
Language: TypeScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Node.js server with REST API built on top of GoogleChrome/puppeteer.
creenshot/server
docker build -t screenshot .
docker run -p 8787:3000 screenshot
Set the number of browsers running in Dockerfile
as an argument to server.js
Important
url
query param needs to be url_encoded for all endpoints
using https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent and https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent
definitions of encoding and decoding
/PNG \ Query Params
localhost:{port}/png?url=https://www.google.com&window=500x500&crop=75x80&x=350&y=190
/JPEG Query Params
localhost:{port}/jpeg?url=https://www.google.com&window=500x500&crop=75x80&x=350&y=190&jpegQuality=50
/PDF \ Query Params
Example
localhost:{port}/pdf?url=https://www.google.com&format=Letter
result: https://www.docdroid.net/223cLO0/pdf.pdf
crop is picked from moving the x, y from top left of the window and the crop size defines the rectangle [(x, y), (x + cropx, y), (x + cropx, y + cropy), (x, y + cropy)].
There is a rate limiter set to limit the number of requests in a 3 second window to number of browsers open (set in Dockerfile) so if 10 browsers are open and 11 requests get made within 3 seconds the 11th will fail, it will be up to the client to retry.
Each endpoint forwards the giving http headers to puppeteer so you can access pages that require auth
Screenshot is licensed under the MIT license. GoogleChrome/puppeteer is licensed under the Apache License 2.0.