How to Build a Web Scraper With Claude Code: the Polite Scrape Method

David IyaDavid Iya July 5, 2026 10 min read
A dew-covered spiderweb backlit by morning sunlight.
Photo via Pexels

How to Build a Web Scraper With Claude Code

To build a web scraper with Claude Code, follow the Polite Scrape, our four-step method at Claude Code Club for pulling data off a web page without writing code yourself. In one breath: pick one page and the exact data you want, check the site's rules, let Claude write the scraper, then run it slowly and save the data. A web scraper is simply a small program that reads a page and copies out the pieces you care about, and Claude Code writes that program for you inside the Claude desktop app.

Your job is to decide what data you want and where it lives. Claude handles the code. The one habit that separates a scraper you can be proud of from one that gets you blocked is politeness: only take public data, follow the site's stated rules, and go slowly. Get that right and scraping becomes a calm, repeatable tool instead of a risky hack.

  1. Pick one page and write down the exact data you want.
  2. Check the site's rules so you scrape within them.
  3. Let Claude write the scraper that reads the page and pulls the data.
  4. Run it slowly and save the data somewhere you can use it.

Step One: Pick One Page and the Exact Data You Want

Start by picking one page and naming the exact data you want from it. One page, one short list of fields: the product titles and prices on a single category page, the job titles and locations on one listings page, or the headlines on one news section. A scraper with a narrow, named target is a scraper you can finish and trust. If you cannot say in a sentence what data you want and which page it is on, you are not ready to hand it to Claude yet.

You can always widen the net later. The point of the first build is to get one page scraped cleanly, from request to saved data, so you learn the whole path. A tiny scraper that reliably pulls five fields from one page teaches you far more than an ambitious crawler that never quite runs. Choose the smallest useful version of what you need.

Step Two: Check the Site's Rules Before You Scrape

Before you pull anything, check the site's rules. Most sites publish a file called robots.txt at their main address that says which parts automated tools may read, and their terms of use spell out what is allowed. Ask Claude Code to fetch and explain both for the site you have in mind. This step takes two minutes and it is the difference between responsible scraping and getting your access blocked.

The rule of thumb is simple: collect only public data, take only what you need, and never overload the server. If a page requires a login, if the terms forbid automated access, or if the data is personal information about individuals, stop and find another way. An official API, when the site offers one, is almost always the better and more stable route.

  • Ask Claude Code to read the site's robots.txt and summarize what it permits.
  • Skim the terms of use for any rule against automated access.
  • Confirm the data is public and not behind a login.
  • Prefer an official API if the site provides one.

Step Three: Let Claude Write the Scraper

Next, let Claude write the scraper. Tell Claude Code the page address, the exact fields you want, and that you have checked the site's rules. Ask it to write a scraper that reads that page and pulls those fields, and to explain how each piece works. Claude creates the files and walks you through running it. You do not write any of this code yourself; you describe the goal and Claude builds the tool.

Test it on that one page first. Run it, look at what it pulled, and compare it to the page with your own eyes. If a field is missing or wrong, describe the problem to Claude in plain words and it adjusts the scraper. Web pages are messy, so a little back and forth is normal. Keep refining until the data it returns matches what you see on the page.

  1. Give Claude the page address, the exact fields, and confirmation you checked the rules.
  2. Ask Claude to write the scraper and explain how it works.
  3. Run it on the single page and inspect the data it returns.
  4. Describe any missing or wrong field and let Claude refine it.

Step Four: Run It Politely and Save the Data

Finally, run it politely and save the data. Running politely means adding a short pause between requests so you never flood the server with rapid hits, the way a careful human would browse rather than a machine racing through pages. Ask Claude Code to add a delay between requests and to stop if the site returns an error. This keeps you welcome on the site and keeps your scraper from being blocked.

Then save the data somewhere you can actually use it, such as a spreadsheet file. Ask Claude to write the results to a CSV file, which opens in any spreadsheet app, so your scrape becomes a table you can sort and filter. That is the full Polite Scrape: pick one page and the exact data, check the rules, let Claude write the scraper, and run it slowly while saving the data. You started with a page and ended with a clean table of the data you needed.

  • Ask Claude to add a pause between requests so you scrape at a human pace.
  • Have the scraper stop if the site returns an error or a block.
  • Save the results to a CSV file that opens in any spreadsheet app.
  • Check the saved table against the page one more time before you trust it.

When your scraper works, come share what you built in the Claude Code Club community and tell us the one page and the fields you pulled. Someone will want to gather the same kind of data, and your afternoon becomes their starting point. If you get stuck on rules or on a stubborn page, ask in the community and we will help you sort it out. ⚡

Frequently asked questions

What is the Polite Scrape method?

The Polite Scrape is a four-step Claude Code Club method for building a web scraper: pick one page and the exact data you want, check the site's rules, let Claude write the scraper, then run it slowly and save the data. It is designed so a beginner can go from a page to a clean table of data in an afternoon, without breaking any rules.

Do I need to know how to code to build a web scraper with Claude Code?

No. You decide which page to scrape and which fields you want, and Claude Code writes the scraper and explains how it works. Your job is to name the target, check the site's rules, test the result against the page, and save the data.

Is web scraping legal?

Scraping public data is generally acceptable, but it depends on the site and what you collect. Always read the site's robots.txt file and terms of use first, only take public data, and never pull information behind a login or personal information about individuals. When a site offers an official API, use it instead. If the rules are unclear, ask the site owner or do not scrape.

What is robots.txt and why should I check it?

robots.txt is a file most sites publish that tells automated tools which parts of the site they may read. Checking it before you scrape is how you stay within the site's stated rules. Ask Claude Code to fetch and explain a site's robots.txt so you know what is allowed before you build anything.

How do I scrape without getting blocked?

Scrape politely. Add a short pause between requests so you browse at a human pace rather than flooding the server, take only the data you need, and stop if the site returns an error. Ask Claude Code to build in a delay and an error check. Respecting the site this way is what keeps your access working.

Where does the scraped data go?

Wherever you tell Claude to put it. A common choice is a CSV file, which opens in any spreadsheet app, so your scrape becomes a table you can sort and filter. Ask Claude Code to save the results to a CSV file and to check the table against the page before you rely on it.

Last reviewed by David Iya on July 5, 2026

David Iya

Written by

David Iya

Forbes 30 Under 30 · Y Combinator

Keep reading

Ready to build it yourself?

Join Claude Code Club, the #1 community for learning claude code, for $9/month.

← Back to the blog