@dnxprbs/browser-screenshot
v1.0.1
Published
Puppeteer-based bulk screenshot automation for web pages. CLI & programmatic API.
Maintainers
Readme
@dnxprbs/browser-screenshot
Puppeteer-based bulk screenshot automation for web pages. Works as a CLI tool or a programmatic Node.js API.
Install
npm install @dnxprbs/browser-screenshotCLI
npx @dnxprbs/browser-screenshot config.jsonconfig.json example:
{
"viewport": { "width": 1280, "height": 800 },
"outDir": "/tmp/screenshots",
"routes": [
{ "url": "https://example.com", "name": "home.png", "fullPage": false },
{ "url": "https://example.com/about", "name": "about.png", "fullPage": true }
]
}The CLI exits with code 1 if any route fails.
Programmatic API
const { takeScreenshots } = require('@dnxprbs/browser-screenshot');
const results = await takeScreenshots({
viewport: { width: 1440, height: 900 },
outDir: '/tmp/screenshots',
routes: [
{ url: 'https://example.com', name: 'home.png', fullPage: false }
]
});
// results: [{ url, name, path, success, error? }]takeScreenshots(config)
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| config.viewport.width | number | No | Viewport width (default: 1280) |
| config.viewport.height | number | No | Viewport height (default: 800) |
| config.outDir | string | No | Output directory (default: cwd) |
| config.routes | Route[] | Yes | List of pages to capture |
| config.routes[].url | string | Yes | URL to navigate to |
| config.routes[].name | string | Yes | Output filename |
| config.routes[].fullPage | boolean | No | Full-page capture (default: false) |
Returns Promise<ScreenshotResult[]> where each result contains:
| Field | Type | Description |
|-------|------|-------------|
| url | string | Captured URL |
| name | string | Output filename |
| path | string | Absolute path of saved file (on success) |
| success | boolean | Whether capture succeeded |
| error | string | Error message (on failure) |
Requirements
- Node.js >= 18
- Puppeteer downloads Chromium automatically on install
License
MIT
