How to Crawl a Website Responsibly: Rate Limits and robots.txt

Learn how to crawl a website responsibly with robots.txt checks, rate limits, backoff, sessions, and a careful mobile-proxy workflow.
A blue line-art workflow showing a USB modem, small computer, cloud router, and globe on a dark background.

Crawling a website responsibly starts with reducing the load and following the site owner’s instructions, not with changing IP addresses. A careful crawler identifies itself, reads robots.txt, limits concurrency, backs off on errors, and uses mobile proxies only when a legitimate crawl needs more than one outbound connection.

Why sites limit crawlers

Most blocks are a response to a traffic pattern rather than a single bad request. A crawler that opens many connections at once, requests the same URLs repeatedly, ignores cookies, or keeps retrying after 429 and 403 responses looks expensive or abusive to the origin server.

The fix is to make the crawl smaller, slower, and easier to understand. Proxies can spread requests across your own mobile connections, but they do not turn a disallowed crawl into an allowed one. If the owner asks you to stop, stop or request permission.

Common causes include:

SignalWhat the site may seeBetter response
Burst of parallel requestsA sudden load spike from one clientUse one per-host queue and a low concurrency limit
Repeated identical URLsWasted work and cache missesCanonicalise and deduplicate URLs
429 Too Many RequestsYour request rate is above a server limitHonour Retry-After, then slow the schedule
403 or a clear stop pageThe site does not want this client or pathDo not keep rotating IPs; review permission and terms
Session changes on every pageMany unrelated clients instead of one crawlKeep cookies and relevant headers stable

What you need before crawling

Write down the target domains, URL paths, fields, request frequency, and retention period before you run a job. Limit the first run to a small sample so you can inspect status codes, redirects, response sizes, and the site’s published rules.

You also need:

  1. A clear business reason and a source of permission where the site requires it.
  2. A descriptive User-Agent with a contact or documentation URL.
  3. A URL queue that removes duplicates and stays within the approved host and path scope.
  4. A per-host scheduler, timeout, retry policy, and durable crawl log.
  5. A cache so the same page is not downloaded again when the data has not changed.
  6. Proxies only if the workload genuinely needs multiple source connections and your use is permitted.

If you are building the network yourself, the 4G proxy farm setup guide covers the hardware planning side. The Raspberry Pi mobile-proxy guide explains the basic architecture.

Step 1: Check permission, scope, and robots.txt

Why: a small, permitted crawl is easier to operate and less likely to create a block than a broad crawl launched first.

Fetch https://example.com/robots.txt before crawling that host. RFC 9309 defines the Robots Exclusion Protocol and says that a crawler that successfully downloads the file must follow its parseable rules. It also makes clear that robots.txt is a request to crawlers, not an access-control system; private or restricted data still needs proper authorization.

Use a real User-Agent token and check each URL against the rules. A minimal Python check looks like this:

from urllib.parse import urlparse
from urllib.robotparser import RobotFileParser

USER_AGENT = "ExampleResearchBot/1.0 (+https://example.com/bot)"
target = "https://example.com/catalog/item-123"
parts = urlparse(target)

robots = RobotFileParser()
robots.set_url(f"{parts.scheme}://{parts.netloc}/robots.txt")
robots.read()

if not robots.can_fetch(USER_AGENT, target):
    raise RuntimeError(f"Crawl disallowed for {target}")

The success condition is not merely that the file downloaded. Your queue must exclude disallowed URLs, and your logs should record the robots decision and the time the rules were fetched. Cache the file for a reasonable period and refresh it regularly; RFC 9309 says crawlers should not use a cached copy for more than 24 hours unless the file is unreachable.

For implementation details, see the RFC 9309 Robots Exclusion Protocol and Google’s robots.txt introduction.

Step 2: Set a rate limit and backoff policy

Why: predictable pacing protects the origin and gives your crawler a way to recover without turning a temporary limit into a longer block.

Start with one concurrent request per host and a delay of 2–5 seconds between successful requests. This is a conservative operating starting point, not a universal permission level. Increase or decrease it only after checking the site’s guidance, your agreement with the owner, and the server’s response pattern.

Treat 429 Too Many Requests as a control signal. RFC 6585 defines 429 as rate limiting and says the response may include Retry-After. Parse that header when present. When it is absent, use an exponential backoff with jitter rather than an immediate retry.

import random
import time

def wait_after_limit(response, attempt):
    retry_after = response.headers.get("Retry-After")
    if retry_after and retry_after.isdigit():
        delay = int(retry_after)
    else:
        delay = min(900, 30 * (2 ** min(attempt, 5)))
    time.sleep(delay + random.uniform(0, 3))

Retry only idempotent reads, cap the number of attempts, and keep the backoff state per host. A 5xx response can be transient; a 401, 403, or explicit block page is not an invitation to retry forever. The success condition is a crawl log showing bounded concurrency, a delay before every retry, and a clean stop when the policy says to stop.

Step 3: Keep headers and sessions consistent

Why: a stable, honest client is easier for the site to classify than a script that changes identity on every request.

Use a descriptive User-Agent. Send only headers your client actually needs. Keep cookies for a normal session when the site uses them for pagination or locale, and do not mix cookies from unrelated accounts or jobs.

For a simple public-page crawl, a requests.Session is enough:

import requests

session = requests.Session()
session.headers.update({
    "User-Agent": "ExampleResearchBot/1.0 (+https://example.com/bot)",
    "Accept": "text/html,application/xhtml+xml",
})

response = session.get("https://example.com/catalog", timeout=20)
response.raise_for_status()

Do not copy a browser’s entire header set blindly. Do not spoof a search-engine crawler. If the target requires JavaScript, use the site’s documented or permitted interface where possible, and keep the same pacing rules around browser automation. A successful test returns the expected content type, keeps a coherent session, and records the final URL after redirects.

Step 4: Spread legitimate load across your own mobile connections

Why: a single 4G connection can become the bottleneck when you have separate, approved jobs or need to avoid sending every request through one egress connection.

Mobile proxies help with source-network distribution. They do not replace permission, rate limiting, or a clear User-Agent. Keep a separate per-target scheduler even when requests leave through different mobile connections; otherwise a pool of five dongles can still overwhelm a small site.

With a self-hosted setup, each Huawei E3372 HiLink dongle can provide an HTTP and SOCKS5 endpoint through the routing software. A Raspberry Pi or Linux box can manage the dongles, while the box needs outbound internet access rather than a static public IP or inbound port forwarding. That is useful when the box is behind CGNAT.

ProxyKite’s per-dongle licence is $9 per dongle per month, with traffic carried over your own SIM data plan and no per-GB charge. It supports on-demand changes, rotation links, or timers from 60 seconds to 7 days, with a sticky option. For a crawl, choose a rotation interval that matches the work: keep a session on one connection for paginated or stateful requests, and rotate between independent jobs only when the target’s rules and your use case allow it.

The ProxyKite rotation-links guide shows the control pattern. Configure the scraper to consume the returned proxy endpoint, then verify the endpoint with a harmless request before starting the job. The success condition is that each request uses the intended proxy, the session policy is explicit, and a 403 or stop instruction pauses the job instead of triggering more rotation.

Step 5: Cache, deduplicate, and narrow the URL queue

Why: the cheapest request is the one your crawler never sends.

Normalise URLs before putting them on the queue. Remove tracking parameters that do not change the page, resolve relative links, reject off-domain URLs, and store a hash of each fetched representation. Use conditional requests such as If-None-Match and If-Modified-Since when the server provides an ETag or Last-Modified value.

For price monitoring, schedule only the pages and fields that changed in the past. The guide on proxies for price monitoring covers why a focused URL set is more useful than repeatedly crawling an entire catalogue.

Measure these values per host:

MetricWhy it matters
Requests per minuteShows whether the scheduler is respecting its limit
Unique URLs and duplicate rateFinds queue and canonicalisation bugs
2xx, 3xx, 4xx, and 5xx countsSeparates content changes from access signals
Bytes downloadedProtects both your data plan and the origin
Median and high-percentile latencyShows when the host or route is under pressure
Cache-hit rateIndicates how much repeat traffic you avoided

Success looks like a queue with very few duplicate URLs, a measurable cache-hit rate, and a crawl that reaches its target data without downloading pages it does not need.

Step 6: Verify responses and stop cleanly

Why: a crawler that checks what it received will not quietly save an error page as product data or keep hammering a host after access changes.

Check the status code, Content-Type, final URL, and a small signature of the body before parsing. Some sites return a branded block page with status 200; a sudden change in title, content length, or required marker can expose it. Save a redacted sample for debugging, but do not store credentials, session cookies, or personal data unnecessarily.

Use a stop policy such as this:

  1. Pause the host after repeated 429 responses and honour Retry-After.
  2. Stop the affected path after a 403, authentication wall, CAPTCHA, or explicit owner instruction.
  3. Stop the whole job when the response shape changes unexpectedly across several URLs.
  4. Contact the site owner with your User-Agent, scope, rate, and purpose if access is important.
  5. Resume only after the policy or permission is clear, with a smaller test window.

This is also where you check your own data handling. Crawl public, permitted content only; exclude login, checkout, account, and other sensitive paths unless you have explicit authorization. Do not use proxy rotation to bypass an access control or a platform ban.

Success looks like a complete, auditable run: every saved record has a source URL and response check, and the job can pause without losing its place or retrying a blocked path.

Troubleshooting 403, 429 and challenge responses

SymptomLikely causeWhat to do
429 after a few pagesRate or concurrency is too highRead Retry-After, back off, lower concurrency, and reduce the URL set
403 only through one routeThe origin or network path rejects that sourceStop, verify permission, and ask the owner; do not cycle routes indefinitely
200 responses contain a challenge pageThe response is not the requested documentDetect the body signature, pause the job, and use an approved access method
Data suddenly repeatsCache key or URL normalisation is wrongLog canonical URLs and response validators; deduplicate before fetching
Pagination loses stateRequests are changing sessions or proxies too oftenKeep the session and route sticky for that workflow
Requests time out through a dongleLocal signal, power, or data-path issueTest one endpoint, inspect local hardware, and keep the crawl paused until it is stable

FAQ

Do mobile proxies override a site’s crawl limits?

No. They can distribute traffic across your own mobile connections, but they do not override robots.txt, terms, authentication, rate limits, or a site owner’s decision. A polite scheduler and a permitted scope matter more than the number of IPs.

How many requests per second should a crawler send?

There is no universal safe number. Start with one request at a time per host and a 2–5 second delay, then follow the site’s instructions and response signals. Slow down immediately for 429, rising latency, connection drops, or any explicit request to stop.

Should I rotate the proxy for every request?

Usually not for a stateful session. Keep a route sticky while following pagination or cookies, and rotate only between independent jobs when the target permits it. Rotating every request can destroy session continuity and make the crawl harder to identify and troubleshoot.

Is robots.txt a legal permission to scrape a site?

No. RFC 9309 describes robots rules as crawler instructions, not access authorization. Check the site’s terms, permissions, applicable privacy and data rules, and the sensitivity of the data before you crawl.

Can I run this setup behind CGNAT?

Yes, a self-hosted mobile-proxy box can work with outbound internet access and does not need a static public IP or inbound port forwarding. ProxyKite routes the proxy service through the cloud; you provide the compatible dongles, SIMs, and data plans.

Previous Article

SOCKS5 vs HTTP Proxy: Which One Should You Use?

Next Article

How Often to Rotate a Mobile Proxy IP