mcpField
A
agent-browser-scrape

agent-browser-scrape

github.com/owenleezyData & databases456 installsUpdated 31w ago
Repository

About agent-browser-scrape

An agent-browser skill for extracting data from web pages. It provides an execution sequence for waiting on content, validating selectors, handling pagination, and recovering from common scraping failures.

Key features

  1. 01Wait for network idle before extraction
  2. 02Validate selectors with item counts
  3. 03Handle scrolling and pagination
  4. 04Switch engines when pages are empty
  5. 05Format structured or bounded output

Use cases

  1. 01Extract data from JavaScript-rendered pages
  2. 02Collect items across infinite-scroll pages
  3. 03Recover when bot checks block extraction

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/owenleezy/agent-browser-skill --skill agent-browser-scrape

After installing, type/agent-browser-scrapein Claude Code to confirm it loaded.

Details

From the project README

Data Extraction — Execution Protocol

Internal template. Entry point: agent-browser skill.


NEVER

NEVER `eval` before `wait --load networkidle` — JS-rendered content won't exist yet
NEVER assume lightpanda handles JS-heavy pages — always have a --engine chrome fallback ready
NEVER scrape without checking `get count` first — validates that your selector found items

Execution Sequence

# 1. Try lightpanda first (fastest, no JS overhead)
AGENT_BROWSER_ENGINE=lightpanda agent-browser open <url>
AGENT_BROWSER_ENGINE=lightpanda agent-browser wait --load networkidle

# 2. Understand structure
AGENT_BROWSER_ENGINE=lightpanda agent-browser snapshot -c

# 3. Verify selector finds items before extracting
AGENT_BROWSER_ENGINE=lightpanda agent-browser get count ".item"

# 4. Extract
AGENT_BROWSER_ENGINE=lightpanda agent-browser eval "[...document.querySelectorAll('.item')].map(el => ({
  name: el.querySelector('h2')?.textContent?.trim(),
  price: el.querySelector('.price')?.textContent?.trim()
}))"

# 5. If empty/wrong → fallback to chrome engine
agent-browser open <url>
agent-browser wait --load networkidle
agent-browser get count ".item"    # verify selector still works
agent-browser eval "<same query>"

Note on AGENT_BROWSER_NATIVE=1: This env var was used in older workflows as a shorthand for the Rust daemon. In 0.22+, the daemon is always active — use AGENT_BROWSER_ENGINE=chrome (or just default) instead. AGENT_BROWSER_NATIVE=1 is still accepted but no longer documented.


Pagination Handling

# Scroll-based infinite scroll
agent-browser scroll down
agent-browser wait --load networkidle
agent-browser get count ".item"    # check if count increased
agent-browser eval "<extract again>"
# Repeat until count stops increasing

# Click-based pagination
agent-browser find role button click --name "Next"
agent-browser wait --load networkidle

# Wait for specific text to confirm page loaded
agent-browser wait --text "Page 2 of"

Output Parsing Tips

# Add --content-boundaries to help parse output when using --max-output
AGENT_BROWSER_CONTENT_BOUNDARIES=1 agent-browser eval "<query>" --max-output 50000

# JSON output for structured parsing
agent-browser get text @e1 --json
agent-browser snapshot -i --json

Anti-Bot Bypass

# Level 1: custom user-agent
agent-browser --user-agent "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36" open <url>

# Level 2: disable automation detection (combine with level 1)
agent-browser \
  --user-agent "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36" \
  --args "--disable-blink-features=AutomationControlled" \
  open <url>

Recovery Patterns

FailureRecovery
lightpanda returns emptySwitch to --engine chrome (or default)
Detected as botAdd --user-agent, then combine with --args
eval before content loadswait --load networkidle before every eval
Infinite scroll not handledscroll down + re-eval loop, check get count for progress
Output truncatedAdd --max-output 100000 or AGENT_BROWSER_MAX_OUTPUT env

Judgment Gates

Pause when:

  • Anti-bot measures block all approaches (CAPTCHA requires human)
  • get count returns 0 after fallback — show snapshot -c to user, ask how to identify items

Pitfalls

MistakeFix
lightpanda returns emptySwitch to --engine chrome
eval before loadwait --load networkidle first
Bot detected despite --user-agentAdd --args "--disable-blink-features=AutomationControlled"
Extracted 0 items silentlyAlways get count "<selector>" before eval
Output cut off mid-JSONIncrease --max-output or use --content-boundaries

Comments

Markdown supported