Webpage Capture
Take ultra-high-resolution full-page screenshots of web pages using Playwright (Python). Output is a crisp PNG that remains clear even when zoomed in multiple times.
Prerequisites
- Python 3.10+ with
playwrightpackage installed - Playwright Chromium browser installed (
playwright install chromium)
Quick Start
Run the screenshot script (saves to Desktop by default):
python scripts/capture.py "<URL>"
Or specify a custom output path:
python scripts/capture.py "<URL>" --output "<OUTPUT_PATH>.png"
Workflow
- Receive URL from user (must be a valid http/https URL or local file path)
- Run the capture script with appropriate parameters
- Present the output PNG to the user using
present_files
Script Usage
python scripts/capture.py <URL> [OPTIONS]
Options
| Flag | Default | Description |
|---|---|---|
--output, -o |
Desktop/screenshot.png |
Output PNG file path (default: saved to user's Desktop) |
--scale, -s |
3 |
Device scale factor (1-5). Higher = sharper but larger file |
--width, -W |
1920 |
Viewport width in CSS pixels |
--wait, -w |
2000 |
Milliseconds to wait after page load before capturing |
--full-page |
enabled | Capture full scrollable page (use --no-full-page to disable) |
--selector |
none | CSS selector to screenshot a specific element only |
--padding, -p |
40 |
Padding around screenshot in CSS pixels, color matches page background (set 0 to disable) |
Examples
Basic full-page screenshot at 3x resolution:
python scripts/capture.py "https://example.com" -o page.png
Ultra-high-res (5x scale, 4K width):
python scripts/capture.py "https://example.com" -o hires.png -s 5 -W 3840
Screenshot a specific element:
python scripts/capture.py "https://example.com" -o chart.png --selector "#main-chart"
Local HTML file:
python scripts/capture.py "file:///C:/path/to/page.html" -o local.png
Scale Factor Guide
| Scale | Use Case |
|---|---|
| 1x | Standard screen quality, smallest file |
| 2x | Retina-quality, good balance |
| 3x | Default - very sharp, suitable for reports and presentations |
| 4x | Ultra-sharp for detailed inspection |
| 5x | Maximum detail, large file size |
Pitfalls
- Long pages: Very tall pages may hit browser memory limits. If capture fails, try reducing scale or width.
- Lazy-loaded content: Increase
--waittime (e.g.,--wait 5000) for pages with images or content that loads on scroll. - Authentication-required pages: The script captures publicly accessible pages only. For authenticated pages, additional cookie/login handling would be needed.
- Dynamic content: Pages with animations or auto-playing video may produce inconsistent results. Increase wait time or use
--selectorto target a stable element.
Output
The script prints the output file path on success. Always present the resulting PNG to the user with present_files.