Browser automation

From borghei/Claude-Skills · View interactive version

Browser automation is an AI agent skill from the GitHub repository borghei/Claude-Skills. Generates polite, rate-limited scraper and form-submission scripts (requests, no JS) and audits automation code for blocking and overload risks. Use when writing a permitted scraper, scripting a form post, or reviewing a crawler.

How to use this skill

Skill file

Browser Automation

Category: Engineering

Domain: Web Automation

Overview

The agent uses this skill to write automation that a site owner would accept: identified, rate-limited, robots.txt-aware and resilient to errors. The generated code uses Python requests, so it handles server-rendered HTML only; for JavaScript-heavy pages or full browser control use Playwright (engineering/playwright-pro).

Authorization comes first. Confirm the user may automate the target (their own site, a test environment, a public API, or terms that allow it). Do not help defeat a site's bot protection, CAPTCHAs, logins or rate limits where the site has not allowed automation; the audit tool exists to make permitted automation reliable and polite, not invisible.

When to Use

Clarify First

Before generating automation, settle the inputs below. When one is missing or vague and would change the result, ask about it; when it wouldn't, use a sensible default and say which one you used.

Ask about the two or three inputs that matter most for this request, not the whole list. If the user wants a result straight away, produce it and state your assumptions at the top.

Quick Start Workflow

# 1. Generate a scraper template: polite strategy, robots.txt check, page cap, JSON output
python scripts/scraping_toolkit.py --url https://example.com/catalog --strategy polite --output /tmp/scraper.py

# 2. Generate a form-submission script from a saved page (pages are never fetched)
python scripts/form_automation_builder.py --html-file assets/sample_contact_form.html \
    --base-url https://example.com --output /tmp/form.py

# 3. Audit any automation script before it runs
python scripts/anti_detection_checker.py --file assets/sample_bare_scraper.py   # 68/100, exit 1
python scripts/anti_detection_checker.py --file /tmp/scraper.py                 # 0/100, exit 0

Tools Overview

| Tool | Purpose | Key Flags |

|------|---------|-----------|

| scraping_toolkit.py | Scraper template with delays, backoff, robots.txt check and page cap | --url, --strategy polite\|normal\|aggressive\|gentle, --max-pages, --output-format csv\|json\|jsonl, --no-robots, --output |

| form_automation_builder.py | Field map (required, CSRF, CAPTCHA, uploads) and a requests script for one form | --html-file, --base-url, --form-index, --output |

| anti_detection_checker.py | Risk score from concealment (webdriver masking, fingerprint spoofing, browser-impersonating User-Agent, proxies) and load patterns (sub-second or fixed delays), plus missing protections (rate limit, robots.txt, backoff, jitter, identifying User-Agent) | --file |

All take --format human|json. Default to --strategy polite; use gentle (5-15 s between requests) for small or fragile sites, and aggressive only for targets the user controls or has explicit permission to load-test. Generated scripts send an identifying User-Agent (ExampleCrawler/1.0 (+URL; contact)) that you edit before running; they never rotate User-Agents or proxies.

Exit codes. anti_detection_checker.py: 0 risk below 50, 1 risk 50 or more, 2 missing or unreadable file. The two generators: 0 script generated, 2 missing file, no form found, --form-index out of range, or --url without a saved page.

Done when:

  1. Authorization for the target is confirmed and written down.
  2. The audit scores below 50 and every critical or high signature is fixed or explained.
  3. The script identifies itself (User-Agent with bot name and contact), masks nothing, honours robots.txt and the terms of service, and stops at a page cap.
  4. A dry run against a handful of pages produced the expected fields.

Workflows

Build a Reliable Scraper

  1. Generate the base code with scraping_toolkit.py --strategy polite.
  2. Fill in the selectors, then audit it with anti_detection_checker.py.
  3. Fix critical and high items and add any missing protection.
  4. Run it on a few pages at the polite rate before raising the page cap.

Automate a Form Submission

  1. Save the page HTML locally and pass it to form_automation_builder.py with --html-file (add --base-url so relative actions resolve).
  2. Check the field map: required fields, CSRF token, CAPTCHA (handled manually, never bypassed).
  3. Wire in the data source and validation, then audit the final script.

Anti-Patterns

Hammering the target

Mistake: A loop of requests with no delay, no page cap and no backoff on 429 or 5xx.

Why it happens: It works on the first ten pages, so nobody adds the brakes.

Instead: Use the polite strategy: jittered delays, exponential backoff, a page cap. The audit adds risk for each missing protection.

Evasion instead of permission

Mistake: Rotating proxies and User-Agents to keep scraping a site that blocks the bot.

Why it happens: A block looks like a technical problem.

Instead: Treat a block as the site's answer. Ask for API access or permission, or stop.

requests on a JavaScript app

Mistake: Scraping a single-page app with requests and getting empty templates.

Why it happens: The page looks like HTML in the browser.

Instead: Check the raw response first. If the data arrives via XHR, call that documented endpoint; otherwise use Playwright.

Files

Scope & Limitations

In Scope:

Out of Scope:

Important Caveats:

Reference Documentation

Common Patterns

Polite Scraping

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.