← BlogLessons

Build a Claude scraping skill that checks its data and remembers each site

Build a Claude scraping skill (3 min lesson)

Out of the box, Claude can read a web page. What it does not give you is a scraper: something that pulls the same data from the same site every time you ask. In this lesson we build one as a Claude skill, with no external APIs: just Claude, Python and one file of instructions. Watch the three-minute video above, or read the steps below. The skill and every file from the video are at the end of the page.

What you will build

Two pieces, kept apart on purpose:

  • The skill, a folder with one file, SKILL.md. It tells Claude how to scrape any public page: what to ask first, which tools to try in which order, and how to check the result. It is the same for every site.
  • A recipe per site, in your project under targets/<site>/. Once a site works, Claude saves the script that worked and a short note on how. Next time, it starts from the recipe instead of from zero.

The skill holds the method; the recipes hold what Claude learned about each site. No URL, selector or credential ever goes into SKILL.md.

Step 1: say what you want

"Scrape this URL" is not a task Claude can check. Before any code, the skill makes Claude collect five answers:

  1. The URL of the page.
  2. The fields one record holds, for example title, price and link.
  3. The format: CSV or JSON, and the file name.
  4. How many records you expect at least.
  5. One value you know is on the page, such as a product name or an author.

The last one matters most. It is how Claude can tell real data from a page that only looks like it worked.

Step 2: climb the ladder only when a check fails

Claude starts with the simplest tool that could work and moves up one rung at a time, only when a check explains why.

RungToolUse it when
1requestsThe HTML or JSON the server returns already holds the fields. Fast, no browser.
2curl_cffiA normal browser gets the page, but plain HTTP gets a different answer. It looks like a browser on the wire without launching one.
3PlaywrightJavaScript or a permitted click builds the data in the browser.
StopAsk youA login, a CAPTCHA, an explicit "no" or unclear permission. That is an access question, not a coding problem.

Starting with a browser hides the diagnosis: you never learn whether plain HTTP would have done, and you carry a browser install you did not need.

Step 3: check the data, not the status code

A login page, a cookie banner and an empty app shell all answer HTTP 200. So after every rung Claude checks the result itself:

  • the expected selector or JSON path is there;
  • there are at least as many records as agreed;
  • every required field is filled;
  • the first, middle and last records look right;
  • no login, consent, challenge or error text on the page;
  • a second run returns the same field names;
  • the saved file opens, and its row count is right.

Only then does it say "done". When a check fails, Claude says what it saw, for example "0 records in text/html", which points to the next step far better than a status code.

Step 4: save a recipe for each site

When every check passes, Claude writes the recipe into targets/<host>/:

  • scrape.py, the final scraper with one transport and nothing else;
  • recipe.md: the URL, the method that worked and why the lighter ones failed, the selectors or JSON paths, the fields, the expected value, the normal record count and the date of the last good run.

On the next request for that site, Claude reads the recipe, runs scrape.py and checks the result again. If the site has changed and a check fails, it says which one, climbs the ladder again and updates the recipe.

A real run: same page, different answer

We tried it on quotes.toscrape.com/js, a public practice site made for scraping, where the quotes are drawn by JavaScript.

A quick script without checks. requests gets HTTP 200 and 5,806 bytes of HTML. It looks for div.quote and finds 0 quotes, because the quotes are not in the markup yet. Stop at the status code and you would call it done.

Claude Code with the skill, first run. Claude checked, looked closer and found the quotes sitting in the page as data, in an inline var data = [...] array. So it stayed on the first rung: no curl_cffi, no browser. It followed the pages to the end and saved 100 quotes, none with a missing field, ran the scraper twice to confirm the same output, and wrote the recipe.

Second run. Claude found targets/quotes.toscrape.com/recipe.md, ran the saved script, checked it, and had the same 100 quotes. It also noticed the recipe mentioned a requirements.txt that was missing and added it.

The recipe Claude saved is in the downloads below, exactly as it wrote it.

The whole skill

This is the complete SKILL.md. The sections on the method, the stop rules and the checks follow a widely used simplest-first approach; "Known sites first" and "Save the recipe" add the per-site memory.

---
name: scrape-public-pages
description: Build and verify small scrapers for permitted public pages, with CSV or JSON output, and save a reusable recipe per site.
---

# Scrape public pages

Before writing code, collect the target URL, required fields, output format,
filename, minimum record count, and one expected value from the user.
Ask for any missing value.

## Known sites first

Take the site's host name (for example `example.com`) and look for `targets/<host>/` in the
current project.

- If `targets/<host>/recipe.md` exists, read it and run `targets/<host>/scrape.py`.
  Then run every check under **Verify after each attempt**. If all pass, deliver.
- If any check fails, say which one and what you saw, then start again from
  **Use this order** and update the recipe when you finish.
- If there is no recipe, start from **Before coding**.

## Before coding

1. Confirm the requested page is public and within the scope I described.
2. Inspect robots.txt and note relevant rules. Treat robots.txt as crawler guidance,
   not as permission by itself.
3. Stop and ask me before continuing if the workflow needs login, personal data,
   CAPTCHA, concealed automation, or access that the site denies.

## Use this order

1. Start with Python Requests and a finite timeout.
2. Verify the response body contains the expected record selector or JSON path.
3. If a normal browser gets the permitted public content but Requests returns an
   incompatible response, try curl_cffi with a current generic browser target.
   Do not create a custom fingerprint or domain-specific evasion profile.
4. Use Playwright only if page JavaScript or a permitted interaction creates the data.
5. If a challenge or explicit denial remains, stop. Do not add CAPTCHA solving,
   proxy rotation, stealth plugins, credential capture, or access-control bypasses.

## Verify after each attempt

- Record requested URL, final URL, status, and content type.
- Reject login, consent, challenge, rate-limit, and generic error pages.
- Require the expected selector or JSON path.
- Require at least the agreed number of accepted records.
- Require every requested field on every accepted record.
- Inspect at least three sample records.
- Run the final scraper twice and confirm the schema stays the same.
- Open the saved CSV or JSON and verify its row count and field names.

## Deliver

- One scraper file with a main entry point.
- requirements.txt with direct dependencies only.
- The saved CSV or JSON file.
- One run command I can copy.
- A short verification summary: chosen method, final URL, accepted record count,
  required-field completeness, and any remaining limitation.

Use one transport in the final script. Remove abandoned code and dependencies.
Prefer stable labels and semantic attributes over long generated CSS class chains.

## Save the recipe

When every check passes, save what worked in `targets/<host>/`:

- `scrape.py`: the final scraper, unchanged.
- `recipe.md`: the URL, the method that worked (Requests, curl_cffi or Playwright) and why
  the lighter ones failed, the selectors or JSON paths, the fields, the expected value,
  the normal record count, and the date of the last successful run.

Keep site-specific values in the recipe, never in this file.

Install it

Claude Code. Unzip the skill into ~/.claude/skills/scrape-public-pages/ to use it in every project, or into .claude/skills/scrape-public-pages/ inside one project. Then ask, for example: "Use the scrape-public-pages skill for https://quotes.toscrape.com/js/. Fields: text, author, tags. JSON in quotes.json, at least 10 records, Albert Einstein expected."

Claude on the web. Turn on code execution, open Customize, then Skills, choose Create skill and upload the ZIP.

If Claude does not pick the skill up, name the task and the output more plainly in your request; Claude matches requests against the skill's description.

Download the files

Limits

This skill is for permitted public pages. Review a site's terms and robots.txt before you scrape it, keep the request rate low, and store only the data you need. robots.txt is guidance for crawlers, not permission. The skill stops on logins, CAPTCHAs and explicit denials by design; it does not solve or bypass them.

A skill also does not run on its own. It makes Claude build and check scrapers the same way every time; you still run them and decide what to collect. When the same job runs on a schedule or inside an app, that is the point to move it to a service or an API.

FAQ

Can Claude scrape a website?

Claude can read a page and write and run a small scraper when you give it the URL, the fields, the format and a way to check the result. This skill makes that repeatable and saves what worked for each site.

Why not start with Playwright?

A browser is the heaviest rung. Start with requests when the data is already in the HTML or JSON, and use Playwright only when JavaScript builds the data. In our run, the JavaScript page did not need a browser at all, because the data was in the page source.

Does HTTP 200 mean the scraper worked?

No. Login pages, consent screens and empty app shells all return 200. Check the expected fields, the record count and the saved file instead.

What is the difference between a skill and a recipe?

The skill is the method and stays the same for every site. A recipe is what Claude learned about one site: the script that worked and how. Recipes live in your project, never in the skill.

Need Google results instead?

ScrapeBeaver returns real-time Google search results as clean JSON from one API call, so there is no scraper to build or maintain.

Try it free
Talk to the team

What are you building?

Your message goes to our team on Telegram. See our Privacy Policy.