# 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

```bash
cd ~/.claude/skills/playwright-visit
nix develop
```

## Usage

```bash
# 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
