mirror of
https://github.com/pocketpaw/pocketpaw.git
synced 2026-05-13 21:21:53 +00:00
Comprehensive SEO optimization across 80 documentation pages: Title optimization (all pages): - Replaced generic titles like "Architecture", "Discord", "Slack" with search-intent titles like "PocketPaw Architecture: Event-Driven Message Bus", "Discord Bot Setup: Add PocketPaw to Your Server" - All titles now 50-70 characters with qualifying keywords Meta descriptions: - Expanded 7 short descriptions (under 145 chars) to 150-160 chars - Roadmap description expanded from 76 to 196 chars - Troubleshooting, Codex CLI, OpenCode, WebMCP all expanded H1 heading fixes: - Ensured single H1 per page matching the frontmatter title - All H1 headings updated to match new optimized titles Internal cross-links: - Added Related CardGroup sections to 60+ individual pages - Each links to 2-3 related pages within and across sections - Channels link to channel guides, backends link to Ollama guide, etc. Em dash cleanup: - Replaced em dashes with colons, periods, or double hyphens across multiple files in tools/, channels/, integrations/ Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
101 lines
3.0 KiB
Plaintext
101 lines
3.0 KiB
Plaintext
---
|
|
title: "Browser Automation: Playwright Web Scraping"
|
|
description: "Automate web browsing with PocketPaw using Playwright. The browser tool navigates pages using accessibility tree snapshots instead of screenshots, enabling fast and accurate web interaction."
|
|
section: Tools
|
|
ogType: article
|
|
keywords: ["browser automation", "playwright", "web scraping", "accessibility tree", "headless browser"]
|
|
tags: ["tools", "automation", "browser"]
|
|
---
|
|
|
|
# Browser Automation: Playwright Web Scraping
|
|
|
|
PocketPaw includes a browser automation tool powered by Playwright. Unlike screenshot-based approaches, it uses **accessibility tree snapshots** for reliable, fast interaction.
|
|
|
|
## How It Works
|
|
|
|
The `BrowserDriver` provides:
|
|
|
|
1. **Navigation** - Open URLs and navigate between pages
|
|
2. **Accessibility tree** - Get a structured representation of the page
|
|
3. **Ref map** - Maps reference numbers to CSS selectors for clicking/typing
|
|
4. **Interaction** - Click elements, type text, scroll, using ref numbers
|
|
|
|
### Why Accessibility Tree?
|
|
|
|
Instead of taking screenshots and using vision models, PocketPaw reads the page's accessibility tree. This is:
|
|
|
|
- **Faster** - No image processing or vision API calls
|
|
- **More reliable** - Structured data instead of visual interpretation
|
|
- **Cheaper** - No vision model tokens
|
|
- **Accessible** - Works with any page, including dynamic SPAs
|
|
|
|
## Usage
|
|
|
|
```
|
|
User: Go to news.ycombinator.com and find the top story
|
|
|
|
Agent: [uses browser tool]
|
|
→ navigate to "https://news.ycombinator.com"
|
|
→ accessibility tree shows: [1] "Story Title" link [2] "comments" link ...
|
|
→ click ref 1
|
|
→ read page content
|
|
```
|
|
|
|
## Configuration
|
|
|
|
The browser tool uses Playwright. Install it with:
|
|
|
|
```bash
|
|
curl -fsSL https://pocketpaw.xyz/install.sh | sh
|
|
|
|
# Or add the browser extra manually
|
|
pip install pocketpaw[browser]
|
|
playwright install chromium
|
|
```
|
|
|
|
## NavigationResult
|
|
|
|
Each browser action returns a `NavigationResult`:
|
|
|
|
```python
|
|
@dataclass
|
|
class NavigationResult:
|
|
url: str # Current URL
|
|
title: str # Page title
|
|
accessibility_tree: str # Structured page content
|
|
refmap: dict[int, str] # Ref number → CSS selector mapping
|
|
```
|
|
|
|
## Policy Group
|
|
|
|
The browser tool belongs to `group:browser`. It's included in the `coding` profile.
|
|
|
|
## Installation
|
|
|
|
```bash
|
|
curl -fsSL https://pocketpaw.xyz/install.sh | sh
|
|
|
|
# Or add the browser extra manually
|
|
pip install pocketpaw[browser]
|
|
```
|
|
|
|
This installs `playwright` as an optional dependency. You also need to install browser binaries:
|
|
|
|
```bash
|
|
playwright install chromium
|
|
```
|
|
|
|
## Related
|
|
|
|
<CardGroup>
|
|
<Card title="Web Search" icon="lucide:search" href="/tools/web-search">
|
|
Search the web via Tavily or Brave Search APIs.
|
|
</Card>
|
|
<Card title="Research Tool" icon="lucide:book-open" href="/tools/research">
|
|
Multi-step web research with automatic summarization.
|
|
</Card>
|
|
<Card title="Tools Overview" icon="lucide:wrench" href="/tools">
|
|
Browse all 50+ built-in tools available in PocketPaw.
|
|
</Card>
|
|
</CardGroup>
|