pageshot

module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 2, 2022 License: MIT

README

pageshot

Pageshot is a simple self-hosted tool that enables you to take a screenshot of any webpage.

Features

  • Containerized (browser is delivered within a Docker image).
  • Configurable width and height parameters.
  • Ability to take a full page screenshot.
  • Support for a delayed screenshot.
  • Support for three output image formats (PNG, JPEG and WEBP).
  • Flexible scale and quality factors.
  • Cache screenshots with local file storage or S3.

Demo is available at https://pageshot.herokuapp.com/. Try it by taking a fullpage screenshot of Hacker News. The pageshot instance runs on a free Heroku dyno, so it might be slow.

API

GET /screenshot

Param Type Description Default
url string Target webpage URL Required
width int Viewport width 1440
height int Viewport height 900
scale int Viewport scale factor 1.0
format string Output image format (png, jpeg, webp) png
quality int Output image quiality 70
delay int Delay in milliseconds, to wait before taking a screenshot 0
fullpage bool Capture full page screenshot false

Config

Config is based on environmental variables.

Environmental variable Type Description Default
SERVER_PORT or PORT (for Heroku) int Server's port 8000
SERVER_READ_TIMEOUT duration Maximum duration for reading the entire request, including the body 5s
SERVER_WRITE_TIMEOUT duration Maximum duration before timing out writes of the response 15s
SERVER_IDLE_TIMEOUT duration Maximum amount of time to wait for the next request when keep-alives are enabled 5s
BROWSER_WIDTH int Initial browser's viewport width 1440
BROWSER_HEIGHT int Initial browser's viewport height 900
BROWSER_URL string Remote browser's URL. If specified, pageshot will try to connect to a remote browser, otherwise will try to allocate a local one
STORAGE_TYPE string Type of a storage. local and s3 are currently allowed
STORAGE_LOCAL_DIRECTORY string Path to local storage directory. Applicable if local storage is selected temp dir path
STORAGE_S3_BUCKET string S3 bucket
STORAGE_S3_ENDPOINT string S3 endpoint
STORAGE_S3_ACCESS_KEY_ID string S3 Access Key ID
STORAGE_S3_SECRET_ACCESS_KEY string S3 Secret Access Key
STORAGE_S3_SSL boolean Use SSL for S3 storage false
LOGGER_LEVEL string Logger's level INFO

Directories

Path Synopsis
Package browser contains browser related logic.
Package browser contains browser related logic.
cmd
Package config holds all config related things.
Package config holds all config related things.
local
Package local implements basic local file storage logic.
Package local implements basic local file storage logic.
s3
Package s3 implements S3 storage logic.
Package s3 implements S3 storage logic.
transport
rest
Package rest implements the pageshot's REST API.
Package rest implements the pageshot's REST API.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL