Skip to content

Take a screenshot of a website using the Cloudflare Workers Browser Rendering API

Notifications You must be signed in to change notification settings

pew/cloudflare-workers-browser-rendering

Repository files navigation

Cloudflare Workers Puppeteer

Just playing around with the Workers Browser Rendering API

It'll accept an URL, uses the Browser API to capture a screenshot of the full page and saves it to R2.

install everything:

npm i

create R2 bucket:

npx wrangler r2 bucket create my-bucket

rename wrangler.example.toml to wrangler.toml and add the r2 binding to it:

r2_buckets  = [
  { binding = "puppeteer", bucket_name = "my-bucket"}
]

you may want to make the r2 bucket public so you can access the screenshot directly, the Worker will do an redirect. Put the public bucket url into wrangler.toml as the bucketUrl environment variable.

deploy everything:

npm run deploy

take a screenshot:

https://your-worker.cool.workers.dev/?url=https://www.youtube.com/watch?v=dQw4w9WgXcQ

About

Take a screenshot of a website using the Cloudflare Workers Browser Rendering API

Topics

Resources

Stars

Watchers

Forks