@koex/puppeteer

1.0.3 • Public • Published

Puppeteer as a Service

Getting Started

# Step 1: start browserless chrome
docker run -d -p 3000:3000 --name browserless whatwewant/browserless-chrome:v1-0

# Step 2: start puppeteer service
docker run -d -p 8080:8080 --name puppeteer-as-a-service \
  -e BROWSER_WS_ENDPOINT=ws://browserless:3000 \
  whatwewant/puppeteer:latest

Usage

1. Generate PDF

  • Params
    • url: The URL to site url
      • required: true
    • format: The format of the outputted PDF
      • required: false
      • default: A4
curl -X POST \
  http://localhost:8887/pdf \
  -H 'Content-Type: application/json' \
  -d '{
    "url": "https://www.baidu.com"
  }'

2. Generate Screenshot (Image)

  • Params
    • url: The URL to site url
      • required: true
    • fullPage: When true, takes a screenshot of the full scrollable page
      • required: false
      • default: true
    • encoding: The encoding of the image, can be either base64 or undefined
      • required: false
      • default: none
      • available: base64 | undefined
    • width: The width of the image
      • required: false
    • height: The height of the image
      • required: false
curl -X POST \
  http://localhost:8080/image \
  -H 'Content-Type: application/json' \
  -d '{
    "url": "https://www.baidu.com"
  }'

License

  • MIT

Readme

Keywords

none

Package Sidebar

Install

npm i @koex/puppeteer

Weekly Downloads

2

Version

1.0.3

License

MIT

Unpacked Size

19.2 kB

Total Files

20

Last publish

Collaborators

  • uniquecolesmith