Extracts chosen fields from one public web page into JSON or CSV with CSS selectors, after a robots.txt check, using a polite User-Agent and returning a sample for verification.
--- name: website-scraper description: Extracts specific fields from one public web page (or a short, user-supplied list of pages) using CSS selectors and saves them as JSON or CSV, after checking robots.txt and the site's terms. Writes and runs a small Python script with a descriptive User-Agent and a request delay, and validates the output. Use when asked to pull a table, list, prices, titles or links from a specific web page into structured data. compatibility: Requires Python 3 and network access to the target site. Uses only the standard library (urllib, html.parser, csv, json); pages that build content with JavaScript need a browser automation tool instead. metadata: version: "1.0.0" category: "data-extraction" --- # Website Scraper Single-page, selector-based extraction into structured data. For crawling many pages with pagination, use a crawler workflow instead (for example the `web-scraper` skill). ## When to use / when not to - Use for: one page or a handful of listed URLs whose data is in the HTML: product names and prices, a table, article titles and links. - Do not use for: content behind a login or paywall, sites whose terms or robots.txt forbid it, personal data collection, or data available through an official API or download (use that instead). ## Inputs to collect - URL(s). - Fields to extract and, if known, CSS selectors (`.product-card .title`, `table#rates tr`). If not given, fetch the page once and propose selectors. - Output format (JSON or CSV) and file name. ## Workflow 1. Check permission: - Fetch `https://<host>/robots.txt` and test the URL with Python's `urllib.robotparser` for your User-Agent. If disallowed, stop and tell the user. - Ask the user to confirm the site's terms allow this use if they are unsure. 2. Fetch the page once with a descriptive User-Agent, for example `website-scraper/1.0 (+contact: you@example.com)`. Check the HTTP status and content type. 3. Inspect the HTML and confirm the selectors match. If the data is missing from the raw HTML (rendered by JavaScript), stop and say a browser tool or the site's API is needed. 4. Write a short script (BeautifulSoup if installed; otherwise `html.parser`, remembering that void tags such as `img` and `br` have no end tag) that: - extracts each record as a dict with the requested field names; - strips whitespace, converts numbers and prices to plain values, resolves relative links with `urllib.parse.urljoin`; - records `null` for missing fields instead of skipping silently. 5. For several URLs, wait at least 1-2 seconds between requests (longer if robots.txt sets `Crawl-delay`) and stop on 429 or 5xx responses. 6. Write JSON (`indent=2`) or CSV (header row, UTF-8) and print: record count, fields with missing values, and the first three records for the user to compare with the page. ## Output - A file such as `products.json` or `products.csv`. - A summary: URL, fetched time, record count, missing-field counts, selectors used. ## Safety and limits - No login, CAPTCHA, paywall or rate-limit evasion; no proxies or rotating User-Agents. - Store only the fields requested; avoid personal data. - Selectors break when the site changes; re-check the sample records on each run. ## Example Request: "From https://shop.example.com/sale get each product's name, price and link into sale.csv. Cards are .product-card with .title, .price and an a tag." Result: robots.txt allows `/sale`; one fetch; `sale.csv` with columns `name,price,url` where prices are numbers and links are absolute; summary reports e.g. 24 records and 0 missing prices, plus the first three rows.
Generate a GitHub Actions (or other CI) pipeline from the repo's real scripts, with least-privilege permissions, caching, concurrency and a gated deploy.
Generate a compose.yaml for your app, database and cache with health-checked startup, named volumes and secrets in .env, validated with docker compose config.
Automate notifications and alerts
Illustrative input and expected result. This example is a verification guide, not a recorded model run.
Content reviewed .
An analyst wants the sale page of a shop they are allowed to scrape exported to a CSV for a price comparison.
From https://shop.example.com/sale get each product's name, price and link into sale.csv. Cards are .product-card with .title, .price and an a tag.
The agent checks https://shop.example.com/robots.txt with urllib.robotparser, fetches the page once with a descriptive User-Agent, confirms the selectors match, and writes sale.csv with header name,price,url where prices are numbers ('$1,005.00' becomes 1005.0) and links are absolute. It reports the record count, missing-field counts and the first three rows. If robots.txt disallows the path or the data is rendered by JavaScript, it stops and says why.AI Agent Skills are reusable workflow packages that extend your AI coding assistant with multi-step capabilities. Install Website 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.
Generate a GitHub Actions (or other CI) pipeline from the repo's real scripts, with least-privilege permissions, caching, concurrency and a gated deploy.
Generate a compose.yaml for your app, database and cache with health-checked startup, named volumes and secrets in .env, validated with docker compose config.
Automate notifications and alerts