A Node server that takes screenshots of websites with node-webshot.
npm installnpm start # listens on 8080 by defaultYou can either get the image via an HTTP response, or instruct screenshotter
to save the screenshot in a path within its local filesystem.
The following shell script uses curl to request a screenshot for lucify.com,
receives it in the body of a HTTP response, and pipes the result into img.jpg.
read -r -d '' BODY <<EOF
{
"url": "lucify.com",
"options": {
"streamType": "jpg",
"quality": 90,
"windowSize": {
"width": 2000,
"height": 1500
}
}
}
EOF
echo $BODY | curl -v -X POST -H "Content-Type: application/json" -d '@-' localhost:8080/ > img.jpgThe following shell script uses curl to request the screenshotter running at localhost:8080
to take a screenshot of lucify.com and store it in its local filesystem in /tmp/screenshot.jpg.
On success, the screenshotter responds with status code 200.
read -r -d '' BODY <<EOF
{
"url": "lucify.com",
"fileName": "/tmp/screenshot.jpg",
"options": {
"streamType": "jpg",
"quality": 90,
"windowSize": {
"width": 2000,
"height": 1500
}
}
}
EOF
echo $BODY | curl -v -X POST -H "Content-Type: application/json" -d '@-' localhost:8080/Screenshotter can be run in Docker. Docker needs to be installed in order to run these commands.
Build Docker image with
docker build -t screenshotter .You can then run it with
docker run --rm -ti -e 'DEBUG=1' -p 8080:8080 screenshotterThere's an issue with webshot on newer node versions, so we install it straight
from a Pull Request.