skills/skills/playwright-visit/README.md
dan d24bedcab3 feat: add playwright-visit skill for browser automation
- 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>
2025-12-29 00:09:50 -05:00

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

  1. Launches headless Chromium using system binary
  2. Creates fresh browser profile (no cookies/logins)
  3. Navigates to URL and waits for network idle
  4. Extracts requested content
  5. 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