Crawls a public site across paginated pages with robots.txt checks, Crawl-delay and rate limits, deduplicates items and saves JSON, CSV or Markdown plus a run report.
--- name: web-scraper description: Plans and runs a polite multi-page crawl of a public website, following pagination or listing links, honouring robots.txt (RFC 9309) and Crawl-delay, rate-limiting requests, deduplicating URLs and saving cleaned records to JSON, CSV or Markdown with a run report. Use when asked to collect data across many pages of a site, such as all items in a paginated catalog, directory or archive. compatibility: Requires Python 3 and network access to the target site. Uses the standard library by default; JavaScript-rendered sites need a browser automation tool such as Playwright, which this skill does not install. metadata: version: "1.1.0" --- # Web Scraper Crawls several pages of one site with explicit limits. For a single page, a simpler selector extraction is enough (see the `website-scraper` skill). ## When to use / when not to - Use for: paginated listings (`?page=2`, "Next" links), category trees, archives, where the user needs every item. - Do not use for: logged-in or paywalled areas, sites whose robots.txt or terms disallow it, personal data harvesting, or anything with an official API or bulk export (use that). ## Inputs to collect - Start URL and the scope (same host only; optional path prefix such as `/products/`). - Item selector and field selectors, e.g. item `.product-card`; fields `name: .title`, `price: .price`, `image: img[src]`. - Pagination: the "next page" selector (for example `a[rel=next]`) or a URL pattern. - Limits: max pages (default 20) and max items; delay between requests (default 2 seconds). - Output format and file name; a contact address for the User-Agent. ## Workflow 1. Check robots.txt with `urllib.robotparser`: `can_fetch(user_agent, url)` for the start URL and every new URL, and `crawl_delay(user_agent)`. `Crawl-delay` is not part of RFC 9309, but honour it when a site sets it: use the larger of that value and the user's delay. If the start URL is disallowed, stop. 2. Fetch the first page and confirm the selectors return items. If items are rendered by JavaScript, stop and explain. 3. Write the crawler (a short Python script) with: - a queue starting at the start URL; a `seen` set of normalized URLs (drop fragments; resolve with `urljoin`); - same-host and path-prefix checks; the max-pages limit; - `time.sleep(delay)` between requests and a descriptive User-Agent such as `web-scraper/1.1 (+mailto:you@example.com)`; - stop on HTTP 429 or repeated 5xx; record 4xx pages in the report and continue; - item extraction to dicts, trimming whitespace and converting prices/numbers; dedupe items by URL or a key field. 4. Run it against the first two pages only and show the user the sample records and the next-page URLs found. Continue to the limit after they confirm. 5. Save the output (JSON array, CSV with header, or a Markdown table) and a run report. ## Run report ``` start: https://example.com/products?page=1 pages fetched: 7 skipped by robots.txt: 0 items: 164 (3 duplicates removed) missing price: 2 errors: 1 x 404 (/products?page=8) delay: 2.0 s user-agent: web-scraper/1.1 (+mailto:you@example.com) ``` ## Safety and limits - Stay within the agreed host, prefix and page limit; never parallelize requests to one site. - No login, CAPTCHA, paywall or block evasion, rotating proxies or fake browser User-Agents. - Keep only the requested fields; do not collect personal data without a lawful reason the user states. - Re-check selectors before reruns; sites change. ## Example Request: "Collect name, price and image URL for every product starting at https://shop.example.com/products?page=1, following the Next link, max 10 pages, to products.json." Result: robots.txt checked (and any Crawl-delay applied), a two-page sample shown for approval, then a crawl that stops when no Next link remains or at 10 pages, `products.json` with deduplicated items and absolute image URLs, and the run report.
Illustrative input and expected result. This example is a verification guide, not a recorded model run.
Content reviewed .
A researcher needs every product from a paginated catalog they are permitted to crawl, limited to 10 pages.
Collect name, price and image URL for every product starting at https://shop.example.com/products?page=1, following the Next link, max 10 pages, to products.json.
The agent checks robots.txt (can_fetch for each URL and any Crawl-delay), fetches two pages and shows sample records plus the next-page URLs for approval, then continues until no Next link remains or 10 pages are fetched, sleeping between requests. products.json holds deduplicated items with numeric prices (null when missing) and absolute image URLs, followed by a run report with pages fetched, robots skips, duplicates removed, missing-field counts and any 4xx/5xx errors.
AI Agent Skills are reusable workflow packages that extend your AI coding assistant with multi-step capabilities. Install web-scraper by following these steps.
SKILL.md inside, in the location documented by your client. Do not assume every AI application reads the same directory.Requires an Agent Skills-compatible client; supported locations and activation vary by version. Read the SKILL.md setup guide. MCP connects tools and data and does not, by itself, install a skill.