- visit.py CLI with subcommands: screenshot, text, html, pdf - Uses system chromium on NixOS (no browser download) - Fresh profile each run (no cookies/history) - flake.nix provides playwright devShell - Options: --wait, --full-page Useful for JS-heavy sites where WebFetch fails. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1.6 KiB
1.6 KiB
playwright-visit
Browser automation using Playwright for visiting web pages, taking screenshots, and extracting content.
Overview
Uses headless Chromium to render pages (including JavaScript) and extract content. Useful for:
- Screenshots of web pages for visual analysis
- Extracting text from JS-heavy sites (where WebFetch fails)
- Getting rendered HTML after JavaScript execution
- Saving pages as PDF
Prerequisites
- NixOS with system chromium (
/run/current-system/sw/bin/chromium) - Playwright Python package (provided via flake.nix)
Setup
cd ~/.claude/skills/playwright-visit
nix develop
Usage
# Screenshot
./scripts/visit.py screenshot "https://example.com" /tmp/shot.png
./scripts/visit.py screenshot "https://example.com" /tmp/full.png --full-page
# Extract text
./scripts/visit.py text "https://example.com"
# Get rendered HTML
./scripts/visit.py html "https://example.com"
# Save as PDF
./scripts/visit.py pdf "https://example.com" /tmp/page.pdf
# Wait longer for slow pages (default: 1000ms)
./scripts/visit.py screenshot "https://slow-site.com" /tmp/shot.png --wait 3000
How It Works
- Launches headless Chromium using system binary
- Creates fresh browser profile (no cookies/logins)
- Navigates to URL and waits for network idle
- Extracts requested content
- Closes browser
Limitations
- No authentication support (fresh profile each run)
- Requires NixOS with system chromium
- Headless only (no visible browser window)
See Also
- WebFetch: For simple HTTP fetches (faster, no browser)
- niri-window-capture: For capturing local application windows