No slash command · from browser-use
Extracts structured data from web pages using browser-use MCP tools. Covers pagination, SPAs, authenticated scraping, rate limiting, and anti-bot handling with JSON/CSV output.
Ships in browser-use. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Patterns for extracting structured data from web pages, including pagination, SPAs, authenticated scraping, and rate-limited crawls.
The fundamental extract-one-page workflow:
1. Navigate to page
mcp__plugin_browser-use_browser-use__browser_navigate(url="https://shop.example.com/products")
mcp__plugin_browser-use_browser-use__browser_list_sessions() → record the new session's id
2. Get DOM state (find data containers and pagination controls)
mcp__plugin_browser-use_browser-use__browser_get_state()
→ interactive_elements: [..., {"index": 2417, "tag": "a", "text": "Next →", "href": "..."}, ...]
(index is the element's Chrome node id, not its position: pass it as given)
3. Extract structured data with LLM-powered query
mcp__plugin_browser-use_browser-use__browser_extract_content(
query="product name, price, SKU, availability for each product listed")
→ "Product: Widget A, Price: $12.99, SKU: WA-001, In Stock\n..."
4. Append to results array
5. Check pagination (see Section 2)
6. Close session when done
mcp__plugin_browser-use_browser-use__browser_close_session(session_id="s1")
7. Write results to file
Write tool → products.json
extract_content vs get_htmlextract_content reads the page text with the agent model (see the
browser-use:agent-model skill) and needs that model's API key; without one it returns
an error naming the variable to set. get_html and browser_evaluate need no model.
| Situation | Tool | Reason |
|---|---|---|
| Data layout is complex or varies per item | extract_content | LLM understands natural variation |
| You know the exact CSS selector | get_html | Faster, cheaper (no LLM call) |
| Extracting a table | get_html(selector=".data-table") | Raw HTML is easier to parse programmatically |
| Extracting a product listing with many fields | extract_content | LLM handles field extraction |
| Page has inconsistent markup | extract_content | Semantic understanding handles inconsistency |
For sites with ?page=N URL patterns:
base_url = "https://shop.example.com/products"
all_results = []
for page in range(1, max_pages + 1):
url = f"{base_url}?page={page}"
mcp__plugin_browser-use_browser-use__browser_navigate(url=url)
state = mcp__plugin_browser-use_browser-use__browser_get_state()
# Check if page has content (stop if we reach an empty page)
if "No products found" in str(state["interactive_elements"]):
break
data = mcp__plugin_browser-use_browser-use__browser_extract_content(
query="all product names, prices, and URLs")
all_results.append(data) # extract_content returns plain text
# Rate limit: pause between pages
Bash: sleep 1
For sites with a "Next" or ">" button:
browser_navigate(url=start_url); session_id = new entry in browser_list_sessions()
all_results = []
page = 0
LOOP:
page += 1
state = browser_get_state()
# Extract data on current page
data = browser_extract_content(query="...")
all_results.append(data)
# Find next button in interactive_elements
next_index = find_next_button(state["interactive_elements"])
# Look for: text contains "Next", "›", "»", or href with page+1
if next_index is None or page >= max_pages:
BREAK # No more pages
browser_click(index=next_index)
# After the click the page may replace its elements, and their old indices
# stop working: call get_state again in the next iteration, never reuse one
browser_close_session(session_id)
Finding the "next" button: Look in interactive_elements for elements with:
text containing: "Next", "›", "»", ">", "Load more"href containing: page=N+1, offset=, cursor=index, tag, text, and placeholder or href
when present. text is the accessible name, so an icon-only button with
aria-label="Next page" shows "Next page". One with no label at all shows an empty
text: find it with browser_get_html and click it with browser_evaluate.For pages that load more content as you scroll down:
browser_navigate(url=start_url); session_id = new entry in browser_list_sessions()
all_results = []
previous_count = 0
LOOP (max 20 scrolls):
# Extract current visible items
data = browser_extract_content(query="all items visible")
current_count = count_items(data)
if current_count == previous_count:
BREAK # No new items loaded — end of list
all_results.extend(new_items(data, previous_count))
previous_count = current_count
# Scroll down to trigger next batch
browser_scroll(direction="down")
# Wait for lazy-load: call get_state twice (SPA needs render time)
browser_get_state()
browser_get_state()
browser_close_session(session_id)
Always set a max_pages limit to prevent runaway scrapes:
max_pages = 50 # Hard stop
rate_limit_ms = 1000 # 1 second between pages
timeout_items = 1000 # Stop if collected 1000 items
SPAs (React, Vue, Angular) render content via JavaScript after the initial HTML load. browser_navigate may return before JS rendering completes.
1. browser_navigate(url="https://spa-app.com/products")
→ response arrives, but DOM is still rendering
2. browser_get_state()
→ interactive_elements may be sparse (only skeleton/loading elements)
3. browser_get_state() ← call again after first render
→ interactive_elements now has actual content
4. If still sparse:
browser_scroll(direction="down") ← trigger rendering
browser_get_state() ← try once more
Signs the page is still loading in interactive_elements:
"Loading...", "Fetching...", "Please wait"skeleton, placeholder, shimmerSigns the page is loaded:
Some SPAs use hash routing (#/products). Navigate with the full URL including hash:
browser_navigate(url="https://app.example.com/#/dashboard/reports")
Scraping behind a login wall — two strategies:
# 1. Navigate to login page
browser_navigate(url="https://site.com/login")
# 2. Fill credentials
state = browser_get_state()
# Find username input in interactive_elements → index N
# Find password input in interactive_elements → index M
browser_type(index=N, text="[email protected]")
browser_type(index=M, text="password123")
# 3. Submit
# Find submit button in interactive_elements → index P
browser_click(index=P)
# 4. Verify login succeeded
state = browser_get_state()
# Check: no login form present, dashboard elements visible
# 5. Export session for future use
browser_export_session(
session_id=session_id,
output_path="~/.browser-use/sessions/site-session.json"
)
# 6. Proceed to scrape protected pages...
# Import cookies from previous login session
browser_import_session(
import_path="~/.browser-use/sessions/site-session.json",
navigate_to="https://site.com/dashboard"
)
→ {"session_id": "restored_xyz", "cookies_imported": 12, …}
# Verify session is still valid
state = browser_get_state()
# If login form visible → session expired, fall back to Strategy A
# If dashboard visible → proceed with scraping
FUNCTION check_logged_in(expected_element_text):
state = browser_get_state()
for element in state["interactive_elements"]:
if expected_element_text in element.get("text", ""):
return True
return False # Session expired
Scraping too fast can trigger anti-bot measures (IP bans, CAPTCHAs, 429 errors). Apply rate limits.
# After each page navigation:
Bash: sleep 1 # 1 second between page loads
# For polite crawling of small sites:
Bash: sleep 3 # 3 seconds between requests
More realistic delay pattern to avoid detection:
# Between pages, use random delay 1-3 seconds
Bash: python3 -c "import time, random; time.sleep(random.uniform(1, 3))"
Watch for these signals in browser_get_state responses:
"Access Denied", "403 Forbidden", "Bot Detected", "Cloudflare"/challenge, /captcha, /blockedinteractive_elements dominated by CAPTCHA widgetsOn bot detection: Stop scraping. Consider a cloud session (browser_start_cloud_session), which includes stealth mode, proxy rotation, and CAPTCHA handling, and drive it with the same page tools. retry_with_browser_use_agent does not help here: it runs a local Chromium of its own and meets the same block.
all_results = []
for each page:
data = browser_extract_content(query="product name, price, URL")
all_results.append(data) # plain text from the agent model
After scraping all pages, write results using the Write tool:
# Write as JSON array
Write tool → products.json:
[
{"name": "Widget A", "price": "$12.99", "url": "..."},
{"name": "Widget B", "price": "$24.99", "url": "..."}
]
For tabular data, write as CSV:
Write tool → products.csv:
name,price,sku,availability
Widget A,$12.99,WA-001,In Stock
Widget B,$24.99,WB-002,Out of Stock
For large scrapes (hundreds of pages), write incrementally rather than accumulating in memory:
# Every 10 pages, append to file rather than accumulating all in memory
# Prevents memory issues for large scrapes
# Write partial results after each batch, report running total to user
# WRONG: No max_pages guard — will run until the site has no more pages or crashes
while has_next_page:
scrape_page()
click_next()
# CORRECT: Always set a max
page = 0
max_pages = 100
while has_next_page and page < max_pages:
scrape_page()
click_next()
page += 1
# WRONG: Exception aborts workflow, session never closed
data = browser_extract_content(...) # raises error
browser_close_session(session_id) # never reached
# CORRECT: Close before raising
try:
data = browser_extract_content(...)
finally:
browser_close_session(session_id)
# WRONG: Assume extract_content always works
data = browser_extract_content(query="products")
results.extend(data) # What if page redirected to login? Data is now the login page.
# CORRECT: Verify page content before extracting
state = browser_get_state()
if "Login" in get_page_title(state):
handle_session_expired()
else:
data = browser_extract_content(query="products")
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
web-scraping, data-extraction, pagination, browser-automation
6 skills in this plugin
/agent-modelPicks the LLM retry_with_browser_use_agent and browser_extract_content use. Use when choosing the browser-use agent model, or the user mentions a cheap, slow, or smart model./core-apiReference for the Browser Use MCP tools — parameters, returns, session lifecycle. Use when navigating, clicking, typing, evaluating JS, or extracting page content./debug-uiVisual UI debugging — screenshot capture and analysis, responsive layout checking at multiple viewport sizes, CSS validation via DOM state, visual regression detection, before/after state comparison./hybrid-debuggingCombines Browser Use (DOM, clicks, screenshots) with claude-in-chrome (console, network, JS) for full-spectrum debugging. Use when investigating console errors or network requests./navigation-patternsBrowser Use tab, session and back-navigation patterns, and login reuse via export/import. Use when opening or switching tabs, managing browser sessions, or reusing a login.npx claudepluginhub madappgang/magus --plugin browser-useOther plugins' skills for the same job