coreproxies.com

Home / Blog / Web scraping best practices

Web Scraping Best Practices: A Field Guide

A scraper that works on day one and still works in month six has the same parts every time: a narrow scope, polite fetching, the cheapest proxy that does the job, strict error handling and checks on the data itself. This guide walks through them in order.

7 min readWeb scraping

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:

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:

  1. An official API or data export. Stable, documented, and the site owner prefers you use it.
  2. Sitemaps and feeds. An XML sitemap lists URLs and often last-modified dates, which lets you skip unchanged pages.
  3. 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.
  4. 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.
  5. 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.

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.

TierUse it forBillingFrom
DatacenterPublic pages and APIs at high volumeMonthly: bandwidth tier plus IP count€15 / month
ISPLong sessions on one static, ISP-registered IPMonthly: bandwidth tier plus IP count€18.23 / 250 GB + €0.23 / IP
ResidentialLocation-specific content; sites that expect home connectionsPer-GB packages€0.50 / GB
IPv6Very large crawls of IPv6-reachable targetsPer 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.

ResponseAction
Timeout or connection resetRetry once or twice with a new IP
429 Too Many RequestsWait for Retry-After, lower the rate for that domain
403 ForbiddenDo not hammer; queue for review, check headers and session
404 Not FoundRecord and do not retry; the page is gone
407 Proxy Authentication RequiredFix your proxy credentials; retrying will not help
5xx from the targetExponential backoff; pause the domain if it persists
200 with the wrong contentTreat 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.

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.

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:

What should you check before launch?

Nine points, from scope to alerts.

  1. Scope, fields and refresh interval are written down.
  2. Terms of service and robots.txt have been read.
  3. No API, feed or embedded JSON provides the same data more cheaply.
  4. Per-domain concurrency and randomized delays are configured.
  5. A sample run on the lowest proxy tier has been measured.
  6. Rotating or sticky session is chosen per flow.
  7. Each error class has a defined action and a retry cap.
  8. Records are validated and raw responses are kept.
  9. 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.

Build your crawler on Core Proxies

Create an account, choose your proxy type and plan, and your proxy credentials are available in your dashboard within seconds.