The methods

Every scraping strategy, explained

What each technique does, the site it targets, and when to reach for it. Want to run them live? Open the playground.

How to fetch one page — cheapest first
3 Is there an API? 1 Static HTML? 2 Needs JS?
Then, depending on the job
4 A whole site? 5 Behind login? For an LLM?

1 · Static HTML

requests + BeautifulSoup
The server sends the full HTML. We fetch it and parse it with CSS selectors.
practice site: books.toscrape.com ↗ via API: /api?method=html ↗

2 · Dynamic JS

Playwright (real browser)
JS fills the page. We launch a real browser and read the rendered DOM.
practice site: quotes.toscrape.com/js ↗

3 · Intercepted API

requests → JSON
Behind the JS there's an API with clean JSON. We hit it and skip the HTML.
practice site: quotes.toscrape.com/api ↗ via API: /api?method=json ↗

4 · Crawling at scale

pagination + graph crawlers
Hundreds of pages: walk a 'next' chain, or let BFS / Shark-Search / OPIC order a whole site under a request budget.
practice site: quotes.toscrape.com ↗ via API: /api?method=crawl&query=san+francisco ↗

5 · API with login

session + CSRF token
Data behind a login. We reuse the session cookie/token on every request.
practice site: quotes.toscrape.com/login ↗

Extra · HTML → Markdown

token savings for LLMs
Turns noisy HTML into clean Markdown: same info, a fraction of the tokens.
practice site: quotes.toscrape.com ↗ via API: /api?method=markdown ↗
Advanced methods

Graph crawling: BFS vs Shark-Search vs OPIC

The web is a graph. A crawler decides which URL to visit next with a limited request budget. BFS sweeps by levels, Shark-Search chases a topic (best-first with inherited scores), OPIC computes page importance online like a live PageRank. Same loop, different ordering — run all three on a site and compare.

BFS

Classic level-order sweep: every link gets the score score = −(depth + 1) so the closest pages to the seed are visited first. Uniform coverage, but blind to the topic: it spends requests on /login just like on /blog.

Shark-Search

Topical best-first. Each link blends what its parent passed down with its own anchor + URL words: score = γ·inherited + (1−γ)·local Children of a relevant parent inherit δ·relevance; barren branches decay as δⁿ and die off on their own. The crawler swarms the relevant region of the graph.

OPIC

Online importance, no query needed. The seed starts with cash = 1.0; on each visit the page banks its cash into its history and splits it evenly among its links: cash(child) += cash(page) / out_links Heavily linked pages accumulate cash from many parents and jump the queue — a live PageRank, computed while crawling.