Skip to the workspace
Pebellslearn by building
Data Collection  ›  Capstone Project

Web Scraping

Web Scraping 12 minWeb scraping extracts data from pages built for people, so it is a last resort that must respect the site's rules and breaks when the page changes.

data analyst / Web Scraping

Explore each scene at your own pace.

01 · The rule

The rule

Web Scraping

A new café opened two streets away, and Nisha wants to compare their prices with hers every week. Their menu is on their website, but there is no download and no API. Reading data out of a web page with a program is called web scraping. It works, but it is the most fragile and most carefully governed way to collect data.

The rule

Scrape last, scrape politely, and expect it to break.

A web page is built from HTML, text wrapped in tags. A scraper downloads that HTML and picks out the parts it needs by their tags and classes:

<div class="menu-item">
  <span class="name">Cold coffee</span>
  <span class="price">₹130</span>
</div>

A scraper here would find every menu-item, then read its name and price, giving a table like Cold coffee, 130.

Scrape last. Look for a better door first: an official API, a downloadable file, a public dataset, or simply asking the owner.

Scrape politely.

  • Read the site's terms of use. Some forbid automated collection.
  • Check robots.txt (for example rival-cafe.example/robots.txt), where sites list paths they do not want bots to visit.
  • Go slowly: a few requests spaced apart, not hundreds per second.
  • Take only what you need. Never collect personal data such as reviewers' names without a lawful reason.

Expect it to break. Pages are designed for people and change without warning. If the site renames price to cost, your scraper silently returns nothing. Pages that build their content with JavaScript may send almost empty HTML, which needs heavier tools that run a browser.

Scene 1 of 5
Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.