Glossary Use cases
Web scraping
Web scraping: Web scraping is the automated collection of data from websites, where a program downloads pages and extracts specific information, such as prices, listings or search results, into a structured format.
Also called: data scraping, web data extraction, screen scraping
Key takeaways
- A scraper fetches pages, parses HTML or JSON and stores the fields you need.
- Simple sites need only an HTTP client; JavaScript-heavy sites need a headless browser.
- Proxies spread requests across IPs and locations to avoid rate limits and see local content.
- Most blocks come from request rate, fingerprints and behaviour, not only the IP.
- Legality depends on the data, the method and the jurisdiction; public data is not automatically free to take.
How web scraping works
- Discover URLs: sitemaps, category pages, search results or an API.
- Fetch: request each page with an HTTP client or a headless browser.
- Parse: extract fields with CSS selectors, XPath, JSON parsing or the site’s embedded data.
- Clean and store: normalise values, remove duplicates and save to a database or file.
- Schedule and monitor: rerun regularly and alert when the site’s layout changes.
Common uses
| Use | Example |
|---|---|
| Price monitoring | Tracking competitor prices and stock |
| SERP tracking | Rank positions in search engines by location |
| Market research | Reviews, product catalogues, job ads |
| Ad verification | Checking ads display correctly in each market |
| Brand protection | Finding counterfeit listings |
| Real estate and travel | Listings and fares aggregated from many sites |
| AI and research datasets | Collecting public text, subject to rights and terms |
Tools
- HTTP libraries: Python requests and httpx, Node fetch, Go net/http.
- Parsers: BeautifulSoup, lxml, Cheerio.
- Frameworks: Scrapy, Crawlee.
- Browsers: Playwright, Puppeteer, Selenium.
- Managed services: scraping APIs that handle proxies and rendering.
Why scrapers need proxies
A single IP sending thousands of requests is easy to rate-limit or ban. Proxies help in three ways:
- Scale: spread requests across many IPs with a rotating proxy pool.
- Location: see the prices, results and content shown in each country with geo-targeting.
- Trust: residential and ISP IPs are blocked less than datacenter IPs on protected sites.
Start with datacenter proxies where they work; they are cheaper and faster. Move to residential only for targets that block hosting ranges.
Scraping responsibly
- Read and respect robots.txt and the site’s terms.
- Keep request rates low and back off on errors with exponential backoff.
- Cache pages and avoid re-downloading unchanged content.
- Do not collect personal data you do not need; personal data falls under laws such as the GDPR.
- Do not bypass logins, paywalls or technical access controls.
- Use official APIs when they exist.
Legal basics
Court cases in the US, such as hiQ Labs v. LinkedIn, discussed whether scraping public pages violates the Computer Fraud and Abuse Act, and the outcome left contract and other claims open. In the EU, database rights, copyright and data protection law apply. This is general information, not legal advice; get advice for commercial projects involving personal or copyrighted data.
Choosing an approach
| Approach | Best for | Trade-off |
|---|---|---|
| Official API | Data the site offers through an API | Limits and terms, but stable and clearly allowed |
| HTTP client plus HTML parser | Static pages, high volume | Breaks if the page relies on JavaScript |
| Headless browser | JavaScript-heavy pages | Slower, more bandwidth |
| Scraping API | Teams that want to avoid running infrastructure | Cost per request, less control |
Check for an API first. It is usually faster, more reliable and clearly within the site’s terms.
A minimal scraper with a proxy
import requests
from bs4 import BeautifulSoup
proxy = "http://USER:[email protected]:7777"
r = requests.get("https://example.com/products",
proxies={"http": proxy, "https": proxy},
headers={"User-Agent": "ExampleBot/1.0 (+https://example.com/bot)"},
timeout=30)
soup = BeautifulSoup(r.text, "html.parser")
for item in soup.select(".product-title"):
print(item.get_text(strip=True))
In real projects, add retries with backoff, validation that the page is the real content and not a challenge, and storage for results.
Data quality checks
Scraped data is only useful if it is correct. Validate every run: check that expected fields are present, compare counts with previous runs, flag sudden changes in prices or volumes, and keep raw HTML samples so you can debug parser problems later.
Frequently asked questions
Is web scraping legal?
Scraping public data is legal in many situations, but it depends on the data, how you access it, the site’s terms and local law. Personal and copyrighted data need particular care.
Do I need proxies for web scraping?
For small, polite projects, often not. For large volumes, protected sites or location-specific data, proxies are usually necessary.
Which proxies are best for scraping?
Datacenter proxies for unprotected targets, rotating residential proxies for protected or geo-sensitive targets, and ISP proxies when you need stable sessions.
What is the difference between web scraping and web crawling?
Crawling discovers and visits pages by following links. Scraping extracts specific data from pages. Most projects do both.
How do websites block scrapers?
With rate limits, IP reputation, fingerprinting, JavaScript challenges, CAPTCHAs and honeypot traps.
How much does web scraping cost?
Costs come from proxies (per GB or per IP), servers, development and maintenance. Simple projects on lenient sites can run cheaply on datacenter proxies; strict sites that need residential IPs and browsers cost much more per page.