Public
Like
screenshot
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
index.ts
https://paulkinlan--4f8bcf1c9f7511f0b5cf0224a6c84d84.web.val.run
A simple HTTP service that uses Puppeteer to capture screenshots of websites and return them as binary PNG data.
- Set the
browserlessenvironment variable with your Browserless.io token - The service will be available as an HTTP endpoint
Make a GET request to the service with a url parameter:
GET /?url=https://example.com
url(required): The URL of the website to screenshot
- Success: Returns a PNG image as binary data with
Content-Type: image/png - Error: Returns error message as plain text with appropriate HTTP status code
# Take a screenshot of Wikipedia curl "https://your-val-url.web.val.run/?url=https://en.wikipedia.org/wiki/OpenAI" -o screenshot.png # Take a screenshot of Google curl "https://your-val-url.web.val.run/?url=https://google.com" -o google.png
- Validates URL format before processing
- Sets consistent viewport size (1280x720) for screenshots
- Waits for network to be idle before taking screenshot
- Returns proper error messages for invalid requests
- Includes timeout protection (30 seconds)
The service handles various error cases:
- Missing URL parameter (400)
- Invalid URL format (400)
- Missing browserless token (500)
- Screenshot capture errors (500)
- Viewport: 1280x720 pixels
- Screenshot type: PNG
- Full page: Disabled (captures viewport only)
- Timeout: 30 seconds
- Wait condition: Network idle (no requests for 500ms)