Get your API key

Lesson 3 of 5

Build a small, polite scraper with your agent

Six rules for polite collecting, a Prompt Card that gets your agent to write a safe scraper, and what to do when a site says no.

9 min Log in to open

This course is general information for learning, not legal advice. For business use of collected data, ask a lawyer.

One step at a time, like flipping pages.

By the end of this lesson your AI agent will have written a small, polite scraper that collects 60 books from a practice site into a CSV, and you will know how to check its code and what to do when a site says no.

You need: a coding agent, Python 3 and a terminal (see Open a terminal if that's new) · Time: 9 minutes

  1. We practise on books.toscrape.com, a made-up bookstore built for people learning to scrape. Its makers describe it as a safe place for beginners, so you can't upset a real shop while you learn.

    Your agent will write the code in Python with two add-on packages:

    • requests downloads a web page, like a browser without the screen.
    • Beautiful Soup (package name beautifulsoup4) finds things inside a page's HTML, like "every book title".

    Check Python and install both. On Mac or Linux:

    Terminal · macOS / Linux
    python3 --version
    python3 -m pip install requests beautifulsoup4

    On Windows:

    PowerShell · Windows
    py --version
    py -m pip install requests beautifulsoup4
    Why?

    Practising on a site built for scraping means your mistakes (too fast, wrong pages, a loop) cost nobody anything. You learn the habits first, on a safe target.

Log in free to read the rest of this lesson

Every lesson is free. A free account unlocks all of them and saves your progress.

Still to come in this lesson:

  1. The six rules of a polite scraper
  2. The Prompt Card for your scraper
  3. Read the code before you run it
  4. Run it and check the result
  5. When the site says no
  6. Recap