---
title: "How to scrape a website: free, with your AI, step by step"
description: "Paste one prompt into your AI assistant and get a working Python scraper. We ran it: 1,000 books from 50 pages, saved to CSV."
url: "https://scrapenews.com/guides/how-to-scrape-a-website"
updated: "2026-11-26T00:00:00Z"
---

# How to scrape a website: free, with your AI, step by step

By [scrapenews.com newsroom](https://scrapenews.com/authors/newsroom.md) · Published 16 Nov 2026 · Updated 26 Nov 2026

**TL;DR**

- You’ll build a small program that copies data from a website into a spreadsheet.
- You don’t write the code. You paste one prompt into your AI, and it writes the scraper for you.
- It costs nothing: Python and both libraries are free, and the practice site was made to be scraped.

## What you build, in four steps

You get one file, `scraper.py`. It visits a site page by page, picks out the fields you want, and saves them to `results.csv` (opens in Excel or Google Sheets) and `results.json`.

You need:

- a Windows or Mac computer
- an AI assistant: ChatGPT, Claude, Cursor or similar
- Python (the AI tells you how to check for it and install it)

The steps:

1. Copy the prompt below into your AI.
2. Keep the practice site, or change the two lines at the top to your own site and fields.
3. Follow the AI’s steps to install everything and run it.
4. Open `results.csv`.

The practice site is [Books to Scrape](https://toscrape.com/): a fake bookstore that [calls itself](https://toscrape.com/) “a safe place for beginners learning web scraping”. It has 1,000 books, 20 per page, and needs no JavaScript. Its prices and ratings are [random](https://books.toscrape.com/), so don’t shop there.

**Why Python:** [Beautiful Soup](https://www.crummy.com/software/BeautifulSoup/bs4/doc/), the HTML reader used here, is a Python library, and Scrapy’s [official tutorial](https://docs.scrapy.org/en/latest/intro/tutorial.html) practises on the same sandbox.

A scraper does three jobs, page after page:

- **Fetch:** ask the site for a page, like your browser does, and get back its HTML (the code behind the page). [Requests](https://requests.readthedocs.io/en/latest/) does this part.
- **Parse:** find the bits you want inside that HTML. Beautiful Soup does this part.
- **Save:** write one row per item to a file.

Both libraries are free to use: Requests under the [Apache-2.0 license](https://github.com/psf/requests), Beautiful Soup under MIT.

CSV is a plain table: one line per row, commas between the columns. JSON holds the same data in a shape other programs read easily.

Why a practice site first: it never changes and never blocks you. So when your own site fails later, you know the code works and the site pushed back.

## The prompt to give your AI

Copy all of it. Change only the two lines under “What I want to scrape”.

```text
You are helping me build my first web scraper. I am not a developer, so explain every step in plain words.

What I want to scrape (I filled these in; if a line is empty or unclear, ask me before you write any code):
- Start page: https://books.toscrape.com/
- Fields, one row per item: title, price, availability, star rating, link to the item's page

Build it in Python with the requests and beautifulsoup4 libraries. One file, called scraper.py. Steps:
1. Fetch the start page. Find the repeating block that holds one item and pull out each field I listed. Use the full text, not a shortened one (check attributes like title="" too).
2. Make links absolute (full URLs).
3. Find the "next page" link, follow it, and repeat until there is no next page. Add a MAX_PAGES setting at the top (default 100) so it can never run forever.
4. Save all rows to results.csv and results.json in the same folder as the script.
5. Print one line per page: page number, URL, rows found.

Be polite to the site:
- Wait 1 to 2 seconds between requests (random).
- Send a normal browser User-Agent header, not the library default. Use a timeout of 20 seconds.
- Retry at most 3 times, waiting longer each time, only on network errors, 429 and 5xx. On 429, wait as long as the Retry-After header says if it is there.
- On any other error (403, 404 and so on), stop right away. Print the status code and the URL, keep the rows already scraped, and save them.
- If a page loads but has 0 items, stop and tell me: the site may need JavaScript or the layout changed.

Then tell me how to run it on my own computer, step by step, for Windows and for Mac:
- how to check Python is installed (and where to get it if not),
- how to make a virtual environment and install the two libraries,
- the exact command to run it, and what I should see,
- how to open results.csv in Excel or Google Sheets.

Finish with how to change the start page and fields for a different site, and a short list of what to tell you if it breaks (the status code, the last lines it printed).
```

### Point your AI at scrapenews

Want to skip the guessing and get a stronger scraper straight away? Add this line to the end of the prompt. Your AI then reads our error pages before it guesses a fix.

```text
If the scraper hits an error code or gets blocked, first read https://scrapenews.com/llms.txt, open the matching error page from https://scrapenews.com/errors.md and https://scrapenews.com/guides/how-to-avoid-getting-blocked-scraping.md, then suggest the cheapest fix to try first.
```

Your AI guesses better with a checklist in front of it. Each of our error pages says what the code means, why it happens, and how to fix it.

The addresses end in `.md` and `llms.txt` on purpose. Those are plain-text copies of our pages made for AI assistants: small, no menus, and every link inside leads to another `.md` page.

This works only if your assistant can open web pages. If it can’t, open the page yourself and paste its “Fix it” part into the chat.

Give it evidence too: the status code, the URL, and the last lines the script printed. The main prompt already asks your AI for that list.

Every rule in the prompt is there for a reason:

- **“Use the full text”:** list pages often shorten long names. On Books to Scrape, the full title hides in the link’s `title=""`.
- **MAX_PAGES:** a safety cap. If a “next” link ever points back to itself, the script still stops.
- **User-Agent:** the header that tells a site which program is asking. Left alone, Requests sends [`python-requests/<version>`](https://requests.readthedocs.io/en/latest/_modules/requests/utils/), which announces a script. Here’s [the full header set to send instead](https://scrapenews.com/guides/python-requests-beautifulsoup.md).
- **Timeout:** the [Requests docs](https://requests.readthedocs.io/en/latest/user/quickstart/) say nearly all production code should set one. Without it, a silent server can leave your script hanging forever.
- **Retry only on 429 and 5xx:** both can pass if you wait. A 403 or 404 won’t change by asking again.
- **Retry-After:** a header that tells you how many [seconds to wait](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Retry-After) before you try again.

## We ran it: 1,000 books in under 2 minutes

We gave this exact prompt to Claude Sonnet 5.5 on 2026-11-16, then ran the script it wrote on a Mac.

- It scraped **1,000 rows from 50 pages** in 1 minute 37 seconds, the 1 to 2 second pauses included.
- Every title came out in full. The list page shortens them (“A Light in the …”), so the AI read the full one from the link’s `title=""`.
- It saved the star rating as a number from 1 to 5. The site stores it as a word, like “Three”.
- Pointed at a page that doesn’t exist, it stopped with `Stopped: status 404` and saved what it had.
- With the site and fields left empty, it asked for both before writing any code.

The end of the run looked like this:

```text
Page 49: https://books.toscrape.com/catalogue/page-49.html - 20 rows
Page 50: https://books.toscrape.com/catalogue/page-50.html - 20 rows
No next page - finished.
Saved 1000 rows to results.csv and results.json in ...
```

And the first rows of `results.csv`:

```text
title,price,availability,rating,link
A Light in the Attic,£51.77,In stock,3,https://books.toscrape.com/catalogue/a-light-in-the-attic_1000/index.html
Tipping the Velvet,£53.74,In stock,1,https://books.toscrape.com/catalogue/tipping-the-velvet_999/index.html
```

Your AI may write different code. That’s fine, as long as it follows the rules in the prompt.

What the script did under the hood:

- It found each book in `article.product_pod` and the next page in `li.next a`. Those are CSS selectors: addresses for parts of a page.
- It turned the word rating, like “Three”, into the number 3, so you can sort by it.
- It waited 2, then 4, then 8 seconds between retries, and at most 5 minutes on a `Retry-After`.
- It saved the CSV so the £ sign shows correctly in Excel.

Most of the 97 seconds was the polite pauses: 49 of them, 1 to 2 seconds each. That slowness is on purpose.

Advice: if your AI’s code looks different, ask it to point to each safety rule in its code: the pauses, the timeout, the retries and the stop on errors. If one is missing, ask it to add it.

## When it stops working, read the code it printed

Real sites push back. The script stops and prints a status code (a 3-digit answer from the site). Look it up:

| it printed | what it usually means | read |
| --- | --- | --- |
| `403` | the site refused you | [403 Forbidden](https://scrapenews.com/errors/403-forbidden.md) |
| `429` | you asked too often, too fast | [429 Too Many Requests](https://scrapenews.com/errors/429-too-many-requests.md) |
| a “Just a moment…” page | Cloudflare wants to test your browser first | [Just a moment](https://scrapenews.com/errors/cloudflare-just-a-moment.md) |
| `Attention Required! \| Cloudflare` or `Error code 1020` | a rule the site owner set blocked you | [Cloudflare 1020](https://scrapenews.com/errors/cloudflare-1020.md) |
| 0 items, but you see them in your browser | the page is built by JavaScript, or a bot check caught you | [How to avoid getting blocked](https://scrapenews.com/guides/how-to-avoid-getting-blocked-scraping.md) |
| blocked even when slow and polite | the site may not trust your IP address | [Residential vs datacenter proxies](https://scrapenews.com/guides/residential-vs-datacenter-proxies.md) |
| you need a proxy but have none | how to get one free, plug it in and test it | [Free proxy for web scraping](https://scrapenews.com/guides/free-proxy-for-web-scraping.md) |

Status codes come in [five groups](https://www.rfc-editor.org/rfc/rfc9110#name-status-codes), set by the first digit. The ones you’ll meet most:

- **403:** the server understood the request but refuses to fulfill it.
- **429:** you sent [too many requests](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/429) in a given time. Limits usually count per IP.
- **5xx:** the server failed on a request that looked fine. Often short-lived, which is why the script retries.

“0 items” is the sneaky one. The script got a page, just not the one you see. Either the site builds its list with JavaScript after loading, which Requests never runs (that’s [a job for a browser](https://scrapenews.com/guides/scrape-javascript-sites-playwright.md)), or it sent back a block page. Ask your AI to save that HTML to a file, then open it: you’ll see which.

Advice: don’t reach for a proxy first. A proxy changes only your IP. Slow down and fix your headers before you pay for one.

## Free ways to go further

Keep practising for free. The [Quotes](https://toscrape.com/) sandbox has harder versions of the same task:

- infinite scrolling instead of a “next” button
- quotes that only appear after JavaScript runs
- a login form with a CSRF token (any username and password work)
- a messy, table-based layout

Building an AI agent? Check for a search endpoint before you crawl. Since 25 Nov 2026, sites on Cloudflare can turn on [Search for Agents](https://blog.cloudflare.com/search-for-agents/), Free plan included. Each page then carries a `<meta name="agent:endpoint">` tag, and `/.well-known/search?q=` returns matching text as Markdown. The site’s bot rules still apply. How to spot and use it: [Cloudflare Search for Agents](https://scrapenews.com/news/cloudflare-search-for-agents.md).

Your own site blocks plain requests? Paid tools take over the hard parts, and many let you start free. A few examples from our tool data, A to Z. This is not a ranking. Each value is what the vendor’s own page said when we checked it on 2026-11-16:

| tool | kind | free part |
| --- | --- | --- |
| Bright Data Web Unlocker | scraper API | [5K requests per month](https://brightdata.com/pricing/web-unlocker) |
| Decodo Residential | residential proxies | [100 MB for 3 days](https://decodo.com/proxies/residential-proxies/pricing) |
| Firecrawl | AI scraper | [1,000 credits/month](https://www.firecrawl.dev/pricing) |
| Jina Reader | AI scraper | [10M tokens per new API key; 20 requests a minute without a key](https://jina.ai/reader) |
| Oxylabs Residential | residential proxies | [$5 welcome credit](https://oxylabs.io/pricing/residential-proxy-pool) |
| ScrapeGraphAI | AI scraper | [500 API credits](https://scrapegraphai.com/pricing) |
| ScraperAPI | scraper API | [7-day trial, 5,000 credits](https://www.scraperapi.com/pricing/) |
| ZenRows | scraper API | [5,000 credits/month, no card](https://www.zenrows.com/pricing) |

A scraper API (send it a URL, get the page back) handles proxies, retries and browsers for you. A residential proxy is an IP address borrowed from someone’s home internet. An AI scraper turns pages into clean text or data for a language model.

See every tool, with prices and free tiers side by side:

- [Scraper and unblocker APIs](https://scrapenews.com/compare/scraper-apis.md)
- [AI scrapers and agents](https://scrapenews.com/compare/ai-scrapers.md)
- [Residential proxies](https://scrapenews.com/compare/residential-proxies.md)

“Free” comes in different units, so compare with care:

- **Credits:** one page can cost more than one. [ZenRows](https://www.zenrows.com/pricing) charges 1 credit for a standard page, 5 with JavaScript, 10 with premium proxies. [ScraperAPI](https://www.scraperapi.com/pricing/) also charges more with JavaScript or premium proxies. [Firecrawl](https://www.firecrawl.dev/pricing) charges 1 credit per scraped page.
- **Monthly or once:** Firecrawl’s 1,000 credits come back each month. [ScrapeGraphAI](https://scrapegraphai.com/pricing)’s 500 are one-time.
- **Data:** residential proxies bill per GB. So 100 MB is a size limit, not a page count.
- **Time:** ScraperAPI’s trial ends after 7 days, used or not.

The Quotes sandbox teaches the hard cases one at a time. The JavaScript version shows why “0 items” happens. The Delayed version waits before the quotes appear (`?delay=10000`).

## Open questions

- How other assistants handle this prompt. We tested it with Claude Sonnet 5.5 only.
- How it does on a real site of yours. The practice site never blocks, so our run says nothing about blocks.

Why the first one matters: different AIs write different code from the same words. One may skip the timeout or retry on a 403. That’s why the prompt spells out every rule, and why the “We ran it” section tells you to check them in the code you get.

Why the second one matters: a working run on Books to Scrape proves the code, not your access. Real sites check your IP, speed, headers and browser. So when your own site fails, check for a block first. Start with [How to avoid getting blocked](https://scrapenews.com/guides/how-to-avoid-getting-blocked-scraping.md).

## Related

- [Python web scraping](https://scrapenews.com/guides/python-requests-beautifulsoup.md)  (Read next)
- [What is web scraping? Every question people ask, answered (2026)](https://scrapenews.com/guides/what-is-web-scraping.md)  (Previous)
- [AI scrapers and agents](https://scrapenews.com/compare/ai-scrapers.md)  (Compare)
- [Change monitoring](https://scrapenews.com/compare/change-monitoring.md)  (Compare)
- [Crawling frameworks](https://scrapenews.com/compare/crawl-frameworks.md)  (Compare)
- [Parsing and extraction](https://scrapenews.com/compare/parsing.md)  (Compare)

## Tools for this

| Tool | Price |
| --- | --- |
| [Beautiful Soup](https://scrapenews.com/compare/beautifulsoup.md): Python library for pulling data out of HTML and XML pages. Parses messy markup and lets you search the tree. | Free |
| [Bright Data Web Unlocker](https://scrapenews.com/compare/bright-data.md): Unblocking API from Bright Data: you send a URL, it handles proxies, retries and CAPTCHAs. Billed per 1,000 requests. | $1.50/1k req |
| [Decodo Residential Proxies](https://scrapenews.com/compare/decodo.md): Rotating residential proxies from Decodo (formerly Smartproxy), billed per GB with pay as you go or monthly plans. | $4.00/GB |
| [Firecrawl](https://scrapenews.com/compare/firecrawl.md): Turns websites into Markdown or structured data for AI: scrape, crawl, search, plus Alexandria data tools agents can run. Open source (AGPL) plus a hosted API. | $3.80/1k req |
| [Jina Reader](https://scrapenews.com/compare/jina-reader.md): Converts any URL to LLM-friendly text by adding a prefix (r.jina.ai). Open-source code plus a hosted API. | Free |
| [Oxylabs Residential Proxies](https://scrapenews.com/compare/oxylabs.md): Rotating residential proxies from Oxylabs, billed per GB from one credit plan that also pays for their other proxies and APIs. | $5.00/GB |
| [Requests](https://scrapenews.com/compare/requests.md): The classic simple HTTP library for Python. | Free |
| [ScrapeGraphAI](https://scrapenews.com/compare/scrapegraph-ai.md): Python library that builds scraping pipelines with LLMs from a prompt; also a hosted API with credits. | $5.00/1k req |
| [ScraperAPI](https://scrapenews.com/compare/scraperapi.md): Scraping API that rotates proxies and can render JavaScript. Monthly credit plans; harder pages cost more credits. | $0.49/1k req |
| [Scrapy](https://scrapenews.com/compare/scrapy.md): Python framework for crawling sites and extracting data: request queue, retries, pipelines, exports. Large plugin ecosystem. | Free |
| [ZenRows](https://scrapenews.com/compare/zenrows.md): Scraping API with JavaScript rendering and premium proxies, priced in credits per page. Free plan with 5,000 credits a month. | $0.42/1k req |

## Sources

1. [toscrape.com: Web Scraping Sandbox (Books, Quotes)](https://toscrape.com/) toscrape.com
2. [Books to Scrape: demo website for web scraping](https://books.toscrape.com/) books.toscrape.com
3. [Scrapy docs: Scrapy Tutorial (quotes.toscrape.com)](https://docs.scrapy.org/en/latest/intro/tutorial.html) docs.scrapy.org
4. [Beautiful Soup docs (MIT license)](https://www.crummy.com/software/BeautifulSoup/bs4/doc/) crummy.com
5. [Requests docs: HTTP for Humans](https://requests.readthedocs.io/en/latest/) requests.readthedocs.io
6. [Requests on GitHub (Apache-2.0 license)](https://github.com/psf/requests) github.com
7. [Requests docs: Quickstart (Timeouts)](https://requests.readthedocs.io/en/latest/user/quickstart/) requests.readthedocs.io
8. [Requests source: default_user_agent](https://requests.readthedocs.io/en/latest/_modules/requests/utils/) requests.readthedocs.io
9. [MDN: 429 Too Many Requests](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/429) developer.mozilla.org
10. [MDN: Retry-After header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Retry-After) developer.mozilla.org
11. [RFC 9110 §15: Status Codes](https://www.rfc-editor.org/rfc/rfc9110#name-status-codes) rfc-editor.org
12. [Bright Data: Web Unlocker pricing](https://brightdata.com/pricing/web-unlocker) brightdata.com
13. [Decodo: Residential proxies pricing](https://decodo.com/proxies/residential-proxies/pricing) decodo.com
14. [Firecrawl: Pricing](https://www.firecrawl.dev/pricing) firecrawl.dev
15. [Jina AI: Reader](https://jina.ai/reader) jina.ai
16. [Oxylabs: Residential proxy pricing](https://oxylabs.io/pricing/residential-proxy-pool) oxylabs.io
17. [ScrapeGraphAI: Pricing](https://scrapegraphai.com/pricing) scrapegraphai.com
18. [ScraperAPI: Pricing](https://www.scraperapi.com/pricing/) scraperapi.com
19. [ZenRows: Pricing](https://www.zenrows.com/pricing) zenrows.com
20. [Cloudflare blog: Introducing Search for Agents (2026-11-25)](https://blog.cloudflare.com/search-for-agents/) blog.cloudflare.com

## Up

- [Home](https://scrapenews.com/index.md)
- [Guides](https://scrapenews.com/guides.md)
