This project provides a service to capture screenshots or PDFs of web pages using AWS Lambda and Puppeteer. The service can be configured to capture specific elements, hide certain elements, and set custom dimensions and formats for the output.
Clone the project and install dependencies (only required for code-completion) using Yarn:
yarn install
Build and run the Docker image:
# build Docker image
docker build -t screenshuttle .
# start a test container
docker run -it --rm -p 8080:8080 screenshuttle
Test Lambda execution by sending a test event:
curl -X POST "http://127.0.0.1:8080/2015-03-31/functions/function/invocations" -H "content-type: application/json" -d '{"url": "http://example.com/"}'
There are more options supported by handler than you can pass as event data e.g., as below:
{
"url": "http://example.com/",
"exclude": ["#hide-me", ".hide-me-too"],
"format": "jpeg", # one of jpeg, pdf or png
"fullpage": true,
"selector": "#only-me",
"width": 1280,
"heigt": 720
}