←Learn[← Learn](https://parallel.ai/learn)

November 23, 2026

# Web scraping

Web scraping is the automated extraction of structured fields from public web pages by fetching HTML or rendered DOMs and parsing embedded JSON or selectors into typed records.

Parallel Web Systems avatar
Author: By Parallel Web Systems

Start building with Parallel

Sign up for free. No credit card required.

Start building for free[Start building for free](https://platform.parallel.ai/signup)Contact us[Contact us](https://contact.parallel.ai/)

Web scraping is the automated extraction of structured data—prices, product specs, filings, listings, or article text—from public web pages by downloading their HTML (or rendered DOM) and parsing target fields into JSON, CSV, or a database. Unlike web crawling[web crawling](/learn/web-crawler), which discovers and indexes pages broadly across the internet, scraping targets known page layouts to pull specific records on demand.

### Three-stage web scraping pipeline
```textTarget URLs ──▶ ┌─────────────────────┐
                │   1. Fetch Layer    │ (HTTP client, headless browser,
                │  (proxies / retries)│  or web unlocker)
                └──────────┬──────────┘
                           ▼ raw / hydrated HTML
                ┌─────────────────────┐
                │   2. Parse Layer    │ (CSS / XPath / embedded JSON
                │  (extract fields)   │  or HTML -> markdown)
                └──────────┬──────────┘
                           ▼ typed records
                ┌─────────────────────┐
                │ 3. Clean & Validate │ (dedup, schema check, store)
                └─────────────────────┘```

## How scrapers parse pages under the hood

Most production scrapers avoid fragile regexes and rely on one of three extraction strategies, in order of reliability:

  1. **Embedded JSON / hydration payloads:** Many modern sites embed their full structured state inside `<script id="__NEXT_DATA__" type="application/json">`, `<script type="application/ld+json">`, or an internal XHR endpoint. Parsing that JSON is faster and far less brittle than scraping visual HTML.
  2. **DOM selectors (CSS / XPath):** Libraries such as BeautifulSoup, `lxml`, Cheerio, or Scrapy parse the HTML tree and extract text/attributes from semantic selectors (`[data-testid]`, table rows, headings).
  3. **Headless browser rendering:** When data only appears after JavaScript runs or user clicks, scrapers run Playwright/Puppeteer or call a headless browser API[headless browser API](/learn/headless-browser-api).
### Extracting structured JSON-LD before falling back to HTML selectors
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import json import requests from bs4 import BeautifulSoup def scrape_product_metadata(url: str) -> dict: resp = requests.get(url, headers={"User-Agent": "CatalogSync/1.0"}, timeout=15) resp.raise_for_status() soup = BeautifulSoup(resp.text, "html.parser") # Prefer structured JSON-LD when the site publishes it for script in soup.find_all("script", type="application/ld+json"): try: payload = json.loads(script.string or "") except json.JSONDecodeError: continue if isinstance(payload, dict) and payload.get("@type") == "Product": return { "name": payload.get("name"), "price": (payload.get("offers") or {}).get("price"), "currency": (payload.get("offers") or {}).get("priceCurrency"), "source_url": url, } # Fallback: minimal DOM extraction title = soup.find("h1") return {"name": title.get_text(strip=True) if title else None, "source_url": url}```
import json
import requests
from bs4 import BeautifulSoup
 
def scrape_product_metadata(url: str) -> dict:
resp = requests.get(url, headers={"User-Agent": "CatalogSync/1.0"}, timeout=15)
resp.raise_for_status()
soup = BeautifulSoup(resp.text, "html.parser")
 
# Prefer structured JSON-LD when the site publishes it
for script in soup.find_all("script", type="application/ld+json"):
try:
payload = json.loads(script.string or "")
except json.JSONDecodeError:
continue
if isinstance(payload, dict) and payload.get("@type") == "Product":
return {
"name": payload.get("name"),
"price": (payload.get("offers") or {}).get("price"),
"currency": (payload.get("offers") or {}).get("priceCurrency"),
"source_url": url,
}
 
# Fallback: minimal DOM extraction
title = soup.find("h1")
return {"name": title.get_text(strip=True) if title else None, "source_url": url}
```
Checking embedded JSON-LD or hydration script tags first avoids breaking whenever a site changes CSS class names.

## Web scraping vs. extraction APIs vs. web search APIs

Traditional scrapers break whenever a site redesigns its markup or tightens WAF rules. For AI agents[AI agents](/learn/ai-agent) that read arbitrary unfamiliar domains at runtime, writing per-site selectors is impossible (see web scraper vs. web extraction[web scraper vs. web extraction](/articles/web-scraper-vs-web-extraction)).

ApproachNeeds per-site selectors?Handles arbitrary new URLs?Output shapeBest fit
Custom scraper (Scrapy / Playwright)YesNoExact domain schema (CSV/DB)High-volume monitoring of a small fixed list of sites
Web unlockerYes (still returns raw HTML)PartialRaw HTMLProtected sites where you already maintain custom parsers
Web extraction API (Parallel Extract)NoYesClean markdown / query-focused excerptsFeeding known URLs into LLMs and RAG
Web search APINoYes (discovers URLs too)Ranked URLs + excerptsOpen-web agentic search and data enrichment

## Anti-scraping defenses and legal boundaries

  • - **Common technical defenses:** Rate limiting (`429`), IP/ASN blocking against datacenter ranges, TLS/HTTP2 fingerprinting (`JA3`/`JA4`), JavaScript challenges, and honeypot links.
  • - **Legal and compliance landscape:** Public, logged-off factual data has generally fared better under US computer-access law (for example, _hiQ Labs v. LinkedIn_ and _Meta v. Bright Data_ on logged-off public pages), while bypassing authentication, violating copyright/database rights, harvesting personal data under GDPR/CCPA, or breaching contractual terms carry real legal risk. Always verify compliance with counsel, honor rate limits, and prefer official APIs or licensed web-data providers when available.

## Frequently asked questions

**What is the difference between web scraping and web crawling?**

Web crawling[Web crawling](/learn/web-crawler) discovers and fetches pages broadly by following links to build an index. Web scraping targets specific pages to extract structured fields. Many pipelines crawl first to find URLs, then scrape each URL.

**Why do traditional web scrapers struggle in AI agent workflows?**

An AI agent rarely knows in advance which domains it will encounter, so pre-written CSS selectors cannot cover the open web—and raw scraped HTML floods the model's context window[context window](/learn/context-window) with boilerplate. Extraction and search APIs that output clean, query-focused excerpts solve both problems.

**When is a custom scraper still the right choice?**

When you pull millions of structured rows per week from a handful of known sites (such as your own suppliers or a fixed catalog) where maintaining a handful of dedicated parsers is cheaper than per-URL API pricing.

Start building with Parallel

Start for freeStart building for free[Start for freeStart building for free](https://platform.parallel.ai/signup)Contact us[Contact us](https://contact.parallel.ai/)

## Related Learn pages8

All Learn pages→[All Learn pages](https://parallel.ai/learn)

- [Look-ahead bias](https://parallel.ai/learn/look-ahead-bias)

- [Reward hacking](https://parallel.ai/learn/reward-hacking)

- [RL environment](https://parallel.ai/learn/rl-environment)

- [RLVR (reinforcement learning with verifiable rewards)](https://parallel.ai/learn/rlvr)

- [Prompt caching](https://parallel.ai/learn/prompt-caching)

- [Agent memory](https://parallel.ai/learn/agent-memory)

- [Structured outputs](https://parallel.ai/learn/structured-outputs)

- [Document chunking](https://parallel.ai/learn/document-chunking)

![Company Logo](https://parallel.ai/parallel-logo-540.png)

Contact

  • hello@parallel.ai[hello@parallel.ai](mailto:hello@parallel.ai)

Get updates

Products

  • Task API[Task API](https://parallel.ai/products/task)
  • Responses API[Responses API](https://parallel.ai/products/responses)
  • Monitor API[Monitor API](https://parallel.ai/products/monitor)
  • FindAll API[FindAll API](https://parallel.ai/products/findall)
  • Search API[Search API](https://parallel.ai/products/search)
  • Extract API[Extract API](https://parallel.ai/products/extract)
  • Decisions API[Decisions API](https://parallel.ai/products/decisions)
  • Parallel MCP[Parallel MCP](https://parallel.ai/mcp)
  • Index by Parallel[Index by Parallel](https://index.parallel.ai)
  • Data Connectors[Data Connectors](https://parallel.ai/data-connectors)

Solutions

  • Startups[Startups](https://parallel.ai/startups)
  • Model Labs[Model Labs](https://parallel.ai/solutions/model-labs)
  • Sales[Sales](https://parallel.ai/solutions/sales)
  • Finance[Finance](https://parallel.ai/solutions/finance)
  • Legal[Legal](https://parallel.ai/solutions/legal)
  • Coding & Building[Coding & Building](https://parallel.ai/solutions/code)
  • Life Sciences[Life Sciences](https://parallel.ai/solutions/life-sciences)
  • Insurance[Insurance](https://parallel.ai/solutions/insurance)
  • Productivity[Productivity](https://parallel.ai/solutions/productivity)

Developers

  • Docs[Docs](https://docs.parallel.ai/getting-started/overview)
  • Onboard your Agent[Onboard your Agent](https://docs.parallel.ai/getting-started/overview#onboard-your-agent)
  • Parallel CLI[Parallel CLI](https://docs.parallel.ai/integrations/cli)
  • API Reference[API Reference](https://docs.parallel.ai/api-reference)
  • Python SDK[Python SDK](https://pypi.org/project/parallel-web/)
  • Typescript SDK[Typescript SDK](https://www.npmjs.com/package/parallel-web)
  • Integrations[Integrations](https://parallel.ai/integrations)
  • Changelog[Changelog](https://docs.parallel.ai/resources/changelog)
  • Status[Status](https://status.parallel.ai/)
  • Support[Support](mailto:support@parallel.ai)

Company

  • About[About](https://parallel.ai/about)
  • Press[Press](https://parallel.ai/press)
  • Careers[Careers](https://parallel.ai/careers)
  • Brand[Brand](https://parallel.ai/brand)
  • Museum of the Human Web[Museum of the Human Web](https://museum.parallel.ai/)
  • Parallel Archives[Parallel Archives](https://archives.parallel.ai/)
  • Pioneers[Pioneers](https://pioneers.parallel.ai/)

Resources

  • Blog[Blog](https://parallel.ai/blog)
  • Articles[Articles](https://parallel.ai/articles)
  • Learn[Learn](https://parallel.ai/learn)
  • Demos[Demos](https://parallel.ai/demos)
  • Benchmarks[Benchmarks](https://parallel.ai/benchmarks)
  • Search Capability Leaderboard[Search Capability Leaderboard](https://parallel.ai/leaderboard)
  • Become a Content Partner[Become a Content Partner](https://index.parallel.ai/join)
  • Pricing[Pricing](https://parallel.ai/pricing)
  • Calculator[Calculator](https://parallel.ai/products/search/calculator)

Legal

  • Legal Hub[Legal Hub](https://parallel.ai/legal)
  • Terms of Service[Terms of Service](https://parallel.ai/terms-of-service)
  • Privacy Policy[Privacy Policy](https://parallel.ai/privacy-policy)
  • Report Security Issue[Report Security Issue](mailto:security@parallel.ai)
LinkedIn[LinkedIn](https://www.linkedin.com/company/parallel-web/about/)Twitter[Twitter](https://x.com/p0)GitHub[GitHub](https://github.com/parallel-web)Discord[Discord](https://discord.gg/parallelwebsystems)YouTube[YouTube](https://www.youtube.com/@parallelwebsystems)Events[Events](https://luma.com/parallelwebsystems)
All Systems Operational
![SOC 2 Compliant](https://parallel.ai/soc2.svg)

Parallel Web Systems Inc. 2026

Parallel
Products:[Search API](https://parallel.ai/products/search)[Extract API](https://parallel.ai/products/extract)[Decisions API](https://parallel.ai/products/decisions)[Parallel MCP](https://parallel.ai/mcp)[Task API](https://parallel.ai/products/task)[Responses API](https://parallel.ai/products/responses)[Monitor API](https://parallel.ai/products/monitor)[FindAll API](https://parallel.ai/products/findall)[Index by Parallel](https://index.parallel.ai)[Data Connectors](https://parallel.ai/data-connectors)
Solutions:[Sales](https://parallel.ai/solutions/sales)[Finance](https://parallel.ai/solutions/finance)[Legal](https://parallel.ai/solutions/legal)[Coding & Building](https://parallel.ai/solutions/code)[Life Sciences](https://parallel.ai/solutions/life-sciences)[Insurance](https://parallel.ai/solutions/insurance)[Productivity](https://parallel.ai/solutions/productivity)[Model Labs](https://parallel.ai/solutions/model-labs)
Resources:[Blog](https://parallel.ai/blog)[Benchmarks](https://parallel.ai/benchmarks)[Search Capability Leaderboard](https://parallel.ai/leaderboard)[Integrations](https://parallel.ai/integrations)[About](https://parallel.ai/about)[Press](https://parallel.ai/press)[Museum of the Human Web](https://museum.parallel.ai/)[Parallel Archives](https://archives.parallel.ai/)[Pioneers](https://pioneers.parallel.ai/)[Careers](https://parallel.ai/careers)[Contact Us](https://contact.parallel.ai/)[Become a Content Partner](https://index.parallel.ai/join)
Blog[Blog](https://parallel.ai/blog)Docs[Docs](https://docs.parallel.ai/getting-started/overview)Pricing[Pricing](https://parallel.ai/pricing)
ContactC[Contact](https://contact.parallel.ai/)Log inP[Log in](https://platform.parallel.ai/)