pressly/screenshot

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

Homepage:

Size: 2140

Language: TypeScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Screenshot as a service

Node.js server with REST API built on top of GoogleChrome/puppeteer.

Running screenshot in Docker

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

REST API

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

/JPEG Query Params

/PDF \ Query Params

Example

localhost:{port}/pdf?url=https://www.google.com&format=Letter

result: https://www.docdroid.net/223cLO0/pdf.pdf

NOTES

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

LICENSE

Screenshot is licensed under the MIT license. GoogleChrome/puppeteer is licensed under the Apache License 2.0.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.