Web scraping best practices: a polite guide
Most scraping problems, from error spikes to angry emails, come from scrapers that act nothing like a considerate visitor. These web scraping best practices keep your job cheap to run, easy on the sites you collect from, and on the right side of the basics of the law.
Updated 9 November 2026
Why politeness is a practical choice
A polite scraper is not only the ethical choice. It is also the one that breaks least. Sites run rate limiters, web application firewalls and capacity planning around normal human traffic. A job that sends 50 parallel requests to one small shop will trip those limits, get 429 and 503 responses, and waste bandwidth on retries. A job that reads robots.txt, spaces out its requests and caches what it already has gets clean responses and costs less.
Residential proxies do not change this. Spreading a burst over many IPs still sends the same load to the same server. Use proxies to see a page as a user in a given country sees it, not to send more traffic than the site would accept from one well-behaved client.
1. Read and follow robots.txt
robots.txt is the site’s published statement of what automated clients may fetch. Since 2022 it has a formal specification, RFC 9309. The rules worth knowing:
- Rules are grouped by
User-agent. Use the most specific group that matches your bot’s name, otherwise*. - The longest matching
AlloworDisallowpath wins. - If
robots.txtreturns a 4xx status, the spec lets you crawl. If it returns a 5xx or cannot be reached, treat the whole site as disallowed until it comes back. Crawl-delayis not part of RFC 9309, but many sites still use it. Honouring it costs you little.- Cache the file. The RFC suggests not keeping it longer than 24 hours.
Also look at the Sitemap: lines. A sitemap gives you every URL the site wants found, often with a last-modified date, which saves you from crawling category pages to discover products.
2. Limit your rate and concurrency per host
Think in requests per host, not requests per job. A sensible start is one request every one to two seconds per host with one or two connections open, then adjust based on how the site responds. Large sites with CDNs can take more. Small sites often cannot.
- Slow down when latency rises or when you see
429or503. Those are the site telling you it is busy. - Honour
Retry-Afterwhen the server sends it. Our article on handling 403 and 429 errors has retry code. - Schedule large jobs for the target’s off-peak hours.
- In Scrapy, enable AutoThrottle and set
CONCURRENT_REQUESTS_PER_DOMAIN. See our Scrapy proxy guide.
Here is a small Python client that checks robots.txt and keeps a minimum gap between requests to each host. All traffic goes through the hyperproxy endpoint:
import time
import urllib.robotparser
from urllib.parse import urlsplit
import requests
PROXY = "http://USER-cc-us:PASS@gw.hyperproxy.io:8888"
UA = "acme-price-bot/1.0 (+https://acme.example/bot; bot@acme.example)"
MIN_INTERVAL = 2.0 # seconds between requests to the same host
session = requests.Session()
session.proxies = {"http": PROXY, "https": PROXY}
session.headers["User-Agent"] = UA
robots: dict[str, urllib.robotparser.RobotFileParser] = {}
last_hit: dict[str, float] = {}
def robots_for(origin: str) -> urllib.robotparser.RobotFileParser:
if origin not in robots:
rp = urllib.robotparser.RobotFileParser()
r = session.get(origin + "/robots.txt", timeout=30)
if r.status_code >= 500:
rp.parse(["User-agent: *", "Disallow: /"]) # unreachable: assume full disallow
elif r.status_code >= 400:
rp.parse([]) # no robots.txt: no rules
else:
rp.parse(r.text.splitlines())
robots[origin] = rp
return robots[origin]
def polite_get(url: str) -> requests.Response | None:
parts = urlsplit(url)
origin = f"{parts.scheme}://{parts.netloc}"
rp = robots_for(origin)
if not rp.can_fetch(UA, url):
return None # disallowed: skip it
delay = max(MIN_INTERVAL, rp.crawl_delay(UA) or 0)
wait = last_hit.get(origin, 0) + delay - time.monotonic()
if wait > 0:
time.sleep(wait)
last_hit[origin] = time.monotonic()
return session.get(url, timeout=30)
for url in ["https://example.com/", "https://example.com/products?page=2"]:
r = polite_get(url)
print(url, r.status_code if r is not None else "skipped by robots.txt")The session keeps connections alive, so consecutive requests to one host can reuse the same exit. That is usually what you want for a polite crawl. If you need a fixed IP across a whole flow, use a sticky session.
3. Don’t download what you already have
Caching is the best practice that pays for itself. Most servers send an ETag or Last-Modified header. Send them back as If-None-Match or If-Modified-Since and an unchanged page comes back as 304 Not Modified with no body:
etags: dict[str, str] = {}
def fetch_if_changed(url: str) -> requests.Response | None:
headers = {"If-None-Match": etags[url]} if url in etags else {}
r = session.get(url, headers=headers, timeout=30)
if r.status_code == 304:
return None # unchanged: no body was sent
if "ETag" in r.headers:
etags[url] = r.headers["ETag"]
return rOther ways to fetch less:
- Ask for compressed responses.
requestssendsAccept-Encoding: gzip, deflateby default. With curl, add--compressed. - Use the site’s JSON endpoints or public API when one exists. They are smaller and change less often than HTML.
- Only start a headless browser when the data really needs JavaScript. When you do, skip images, fonts and media.
- Store raw responses so a parser bug does not mean crawling everything again.
Fewer bytes also means a smaller bill, because residential traffic is billed per GB. See how much bandwidth web scraping uses.
4. Identify yourself
Give your bot a descriptive User-Agent with a URL or email address, like the acme-price-bot example above. When a site owner sees unusual traffic, a contact lets them ask you to slow down instead of blocking the whole range. Honour those requests. For commercial monitoring at scale, it is often worth asking the site for permission or a data feed.
5. Collect only what you need, and avoid personal data
Scope your scraper to the fields you use: prices, stock, titles, rankings. Public does not mean free of rules. Under the EU GDPR, a name, a profile or a review author is personal data even when anyone can see it. Processing it needs a lawful basis, a purpose and a retention limit. The safest design is not to collect personal data at all, and to drop it at parse time if it shows up.
Stick to pages any logged-out visitor can see. Content behind a login is governed by the account’s terms, which you agreed to, and is a different legal question.
Is web scraping legal?
This section is general information, not legal advice. The law differs by country and changes. Talk to a lawyer about your use case.
Collecting publicly available data is generally treated far more leniently than accessing data behind a login, but the details depend on how you collect and what you do with it. A few cases and rules come up again and again:
| Source | What it says |
|---|---|
| Van Buren v. United States (2021) | The US Supreme Court read the Computer Fraud and Abuse Act’s “exceeds authorized access” narrowly: it covers entering parts of a system you are not allowed into, not misusing data you can access. |
| hiQ Labs v. LinkedIn (9th Cir. 2022) | The Ninth Circuit held that scraping public profiles likely is not access “without authorization” under the CFAA. The case still ended badly for hiQ on breach-of-contract grounds. |
| Meta v. Bright Data (N.D. Cal. 2024) | A federal court found that scraping public Facebook and Instagram data while logged out did not breach Meta’s terms. It did not decide anything about logged-in scraping. |
| EU DSM Directive, Art. 4 | Allows text and data mining of lawfully accessible content, unless the rights holder has reserved those rights. For content published online, the reservation should be machine-readable. |
Copyright, database rights, contract terms, privacy law and computer misuse law can all apply separately. A clear pattern from these cases: public, logged-out data collected at a reasonable rate, with personal data left out and opt-outs honoured, puts you in a far better position than anything else.
A checklist before you run a job
- The data is public and visible without logging in.
robots.txtallows the paths, and you check it again at least daily.- Per-host rate and concurrency limits are set, and the job slows down on
429and503. - Responses are compressed and cached, with conditional requests for pages you revisit.
- Your
User-Agentnames the bot and gives a contact. - You collect only the fields you need and no personal data you don’t need.
- Retries are capped, so a broken site does not cost you a day of bandwidth.
Where proxies fit
For monitoring jobs, the reason to use residential IPs is accuracy. Prices, stock, search results and ads differ by country and city, and a page fetched from a cloud data center may not match what local users see. Country and city targeting lets you check exactly that. Read geo-targeted price and SERP monitoring for examples, what is a residential proxy for background, and the Python requests guide to wire it up. Pick a provider whose exits come from people who agreed to share them; our article on ethically sourced residential proxies explains why that matters.
FAQ
Is it legal to ignore robots.txt?
In most places robots.txt is not a law in itself, but ignoring it can weaken your position in a dispute, and in the EU a machine-readable opt-out can withdraw the text and data mining exception. Treat it as binding. This is not legal advice.
How many requests per second is polite?
There is no universal number. Start at about one request every one to two seconds per host, honour any Crawl-delay, and back off as soon as response times rise or you see 429.
Do rotating proxies make it fine to send more requests?
No. Rotation changes which IP a request comes from, not how much load reaches the server. Keep your per-host limits whatever your rotation setup.
Can I scrape pages behind a login?
Logged-in pages fall under the terms you accepted when you created the account, and the Meta v. Bright Data ruling did not cover them. Get permission or use an official API.
Try it on your own workload
Sign up with GitHub or Google, create a proxy login and send your first request in a minute.
More blog
- What is a residential proxy? — How residential proxies work, what they are used for, and what to check before you use one.
- Residential vs datacenter vs ISP vs mobile proxies — The four proxy types compared on IP origin, cost model, speed and fit for each job.
- SOCKS5 vs HTTP proxy — How the two protocols differ, what socks5h changes, and which one your client needs.
- How to choose a residential proxy provider — A practical checklist: sourcing, KYC, pricing models, targeting, protocols and testing.
- Ethically sourced residential proxies — What the 2026 IPIDEA and NetNut takedowns mean for buyers, and questions to ask a provider.
- Handling 403 and 429 errors in scrapers — Tell proxy errors from site errors, honour Retry-After, and retry with backoff.
- How much bandwidth does web scraping use? — GB estimates per page type, how to measure your own job, and how to use less.
- Geo-targeted price and SERP monitoring — Collect prices, search results and ads as users in each country and city see them.