What should you define before you write a scraper?
The fields, the pages and the refresh interval, and whether the job is one you should run. Write down exactly which fields you need from which pages, and how fresh they must be. "All product data, updated constantly" produces a crawler ten times larger than "price and stock for 4,000 SKUs, once a day", and the second one is usually what the business needs.
Then check that the job is one you should run:
- Collect public data only. Pages behind a login are governed by the terms you accepted when the account was created.
- Read the site's terms of service and
robots.txt. - Avoid personal data unless you have a lawful basis for processing it; privacy laws apply to scraped data as they do to any other.
- Respect copyright: collecting facts such as prices differs from republishing someone's articles or images.
Proxies are legal when used for legitimate purposes such as web scraping public data, market research and ad verification. Always comply with website terms of service and applicable laws.
Is there a better source than HTML?
Often, yes: an API, a feed or JSON embedded in the page. Rendered HTML is the most expensive and most fragile place to read data from. Before writing selectors, check in this order:
- An official API or data export. Stable, documented, and the site owner prefers you use it.
- Sitemaps and feeds. An XML sitemap lists URLs and often last-modified dates, which lets you skip unchanged pages.
- Structured data in the page. Many product and article pages embed JSON-LD with the same fields you were about to extract with CSS selectors.
- The JSON the page itself loads. Sites that render in the browser fetch their data from an endpoint; reading that response is lighter than running a headless browser.
- A headless browser. Use it when content only appears after scripts run. See browser automation for proxy setup with Puppeteer, Playwright and Selenium.
How do you fetch politely?
Limit concurrency per domain, randomize delays and follow the site's stated crawl rules. Polite crawling is also effective crawling: it avoids blocks, and it keeps the target fast enough to answer you.
- Set concurrency per domain, and start low.
- Randomize delays between requests to the same host.
- Follow
Crawl-delaywhenrobots.txtstates one. - Schedule heavy runs for the target's off-peak hours.
- Send a complete header set, and keep cookies within a session.
The companion article on avoiding IP bans covers pacing and warning signs in more depth.
Which proxy type should you choose?
The cheapest one that returns valid data: start with datacenter proxies and move up only when a target requires it. Proxy cost scales with the type of IP, so move up per domain, not for the whole job.
| Tier | Use it for | Billing | From |
|---|---|---|---|
| Datacenter | Public pages and APIs at high volume | Monthly: bandwidth tier plus IP count | €15 / month |
| ISP | Long sessions on one static, ISP-registered IP | Monthly: bandwidth tier plus IP count | €18.23 / 250 GB + €0.23 / IP |
| Residential | Location-specific content; sites that expect home connections | Per-GB packages | €0.50 / GB |
| IPv6 | Very large crawls of IPv6-reachable targets | Per GB, or unlimited by speed | €0.05 / GB |
Prices exclude VAT. Decide with a sample, not a guess: fetch a few hundred representative URLs on the lower tier and move only the domains that fail. The method is described in how to choose between residential and datacenter proxies.
When should you rotate and when keep a session?
Rotate for stand-alone pages and keep a session for anything that carries state. On Residential plans the username controls sessions: without a session every new connection gets a new IP; add -session- with a number and -ttl- with the time in seconds to keep one.
import requests
ENDPOINT = 'HOST:PORT'
# Independent pages: no session, new IP on every new connection
rotating = 'http://USERNAME:PASSWORD@' + ENDPOINT
# Multi-step flow: keep one IP for 10 minutes
sticky = 'http://USERNAME-session-482913-ttl-600:PASSWORD@' + ENDPOINT
with requests.Session() as s:
s.proxies = {'http': sticky, 'https': sticky}
s.headers['Accept-Language'] = 'en-US,en;q=0.9'
first = s.get('https://example.com/category?page=1', timeout=30)
second = s.get('https://example.com/category?page=2', timeout=30)Replace HOST, PORT, USERNAME and PASSWORD with the values from your dashboard. Rotate for stand-alone pages. Hold a sticky session for anything that carries state: pagination tied to a cookie, a filter set in a previous request, a cart. Give each worker its own session number so that workers do not share an address by accident. On Datacenter and ISP, choose rotating, sticky or static in the Proxy generator of your order.
Which errors should you retry?
Timeouts and 5xx responses with backoff; 429 after waiting; 404 and 407 never. "Retry three times" is not an error strategy, because different failures need different reactions.
| Response | Action |
|---|---|
| Timeout or connection reset | Retry once or twice with a new IP |
| 429 Too Many Requests | Wait for Retry-After, lower the rate for that domain |
| 403 Forbidden | Do not hammer; queue for review, check headers and session |
| 404 Not Found | Record and do not retry; the page is gone |
| 407 Proxy Authentication Required | Fix your proxy credentials; retrying will not help |
| 5xx from the target | Exponential backoff; pause the domain if it persists |
| 200 with the wrong content | Treat as a failure; see parsing checks below |
Cap the total attempts per URL, and send what still fails to a separate queue. A dead-letter queue you inspect once a day finds problems that blind retries hide.
How do you parse defensively?
Check that the page is the one you expected before you read fields from it, and reject records that fail validation.
- Assert, then extract. Before reading fields, confirm the page is the type you expect, for example that a product title element exists. A challenge page or a redirect to the home page returns 200 too.
- Prefer stable anchors. Structured data,
data-attributes and semantic elements change less often than generated class names. - Validate every record. Required fields present, prices numeric and positive, dates parseable, currency known. Reject records that fail instead of storing nulls.
- Keep the raw response. Storing compressed HTML or JSON for a few days lets you re-parse after fixing a selector without fetching again.
- Normalize at the edge. Trim whitespace, unify encodings, and convert units and currencies in one place.
How do you control bandwidth?
Download less: compress, cache and skip assets you do not need. On per-GB plans, bytes are the bill. Residential traffic costs between €2.30 and €0.50 per GB depending on the package, so a crawler that downloads less is directly cheaper.
- Request compressed responses with
Accept-Encoding: gzip, br. - In headless browsers, block images, fonts, video and analytics requests you do not need.
- Use conditional requests (
If-None-Match,If-Modified-Since) where servers support them. - Fetch list pages with the largest page size the site offers.
- Deduplicate URLs before the queue, not after the download.
If a residential workload runs around the clock, compare it with a flat-rate plan: Unlimited Residential charges per day, week or 30 days with unlimited data transfer at a chosen speed tier.
What should you monitor besides the job itself?
The output: valid records, status codes and field fill rates. A crawl can finish with exit code 0 and deliver nothing useful. Track these numbers per domain and alert on changes:
- Share of requests that returned valid, parsed records.
- Distribution of status codes, with 403 and 429 watched closely.
- Median response time and response size; a sudden drop in size often means a different page is being served.
- Records per run compared with the previous run.
- Field fill rate: how often each field is present.
- Bandwidth used per thousand records.
What should you check before launch?
Nine points, from scope to alerts.
- Scope, fields and refresh interval are written down.
- Terms of service and
robots.txthave been read. - No API, feed or embedded JSON provides the same data more cheaply.
- Per-domain concurrency and randomized delays are configured.
- A sample run on the lowest proxy tier has been measured.
- Rotating or sticky session is chosen per flow.
- Each error class has a defined action and a retry cap.
- Records are validated and raw responses are kept.
- Alerts exist for success rate, status codes and record counts.
For workloads built on these steps, see the use-case pages for web scraping, data collection and AI training data.
Frequently asked questions
Is web scraping legal?
Collecting publicly available data is lawful in many situations, but it depends on what you collect, how you use it and where you operate. Read the site's terms, avoid personal data without a lawful basis, respect copyright, and get legal advice for anything commercial at scale.
Do I need proxies for web scraping?
For a few hundred requests a day to one site, usually not. Proxies become necessary when volume from one address would exceed a site's limits, or when you need to see content as it appears in another country or city.
Which proxy type should I start with?
Datacenter. It is fast and the least expensive IPv4 option, from €15 per month. Move a domain to ISP or Residential only when a well-behaved client still fails on datacenter IPs or when you need a location the datacenter network does not cover.
Should I use a headless browser or plain HTTP requests?
Plain HTTP requests when the data is in the HTML or in a JSON endpoint; they are faster and use far less bandwidth. Use a headless browser only when content appears after scripts run and no underlying endpoint is practical to call.
How do I keep scraping costs down?
Fetch only what changed, request compressed responses, block unneeded assets in headless browsers, and route each domain through the least expensive proxy tier that returns valid data.