A scraper that gets blocked usually has one of a handful of problems, and each one needs a different response. After this post you can tell them apart from the response alone, retry with a budget instead of a loop, rotate your identity without breaking your own session, and notice a rising block rate before it becomes an outage.
Technical measures do not decide whether you may collect the data. For that, read is web scraping legal.
Read the response first
Classify every response before you decide what to do. The single most expensive habit in scraping is reading every failure as "needs a captcha solve" — most failures are not captcha problems at all:
| Signal | What it usually is | Next step |
|---|---|---|
| HTTP 403 and a page that says "Just a moment…" | Cloudflare challenge page — a WAF challenge | Challenge solve through a static proxy |
HTTP 403 with a small HTML body containing var dd, or JSON with a url on captcha-delivery.com |
DataDome block — a WAF challenge | DataDome solve; t=bv in the URL means a banned IP, not a solvable challenge |
| HTTP 403, 428 or 429 with "Pardon Our Interruption" | An Akamai edge block or challenge | Check IP reputation, TLS and headers before solving; see the Akamai guide |
HTTP 202 with x-amzn-waf-action: challenge, or a page loading challenge.js |
AWS WAF Challenge (not AWS WAF CAPTCHA) | AWS Challenge; replay the aws-waf-token cookie |
| HTTP 429 | The site is rate-limiting you | Wait, and honour Retry-After when it is sent. Solving here is waste |
| A normal page with a captcha widget inside | A widget, not a block | Identify the type and solve it |
| HTTP 200, but the site says the captcha is invalid or re-renders the form | Application verification failed — the token arrived and was refused | Fix the placement: field name, callback, one-time use. See below |
| HTTP 200, but different content from a browser | A content-level block | Compare the body with what a real browser gets through the same IP |
The last two rows are the easy ones to miss. A scraper that checks only status codes treats a rejected token as success, and an empty result list as data. Keep a known-good copy of a page and compare against it.
Four kinds of denial
Almost every block falls into one of four kinds, and only the first one wants a CAPTCHA solve:
- A WAF challenge. The edge interposes a check (Cloudflare, DataDome, Akamai, AWS WAF, PerimeterX) and a matching task type solves it. The response carries a marker from the table above. Solve, replay the result consistently — same proxy, same user agent — and move on.
- An application verification failure. The token reached the app and the app said no: "invalid captcha", the form re-renders, the session stays logged out. Solving again is usually waste — the solve worked, the delivery did not. Check the three delivery faults: the token went into a field the app ignores (read the real field name, or the page waits for its callback — the submit guide covers both), the token was used twice or arrived late, or the replay presented a different client than the solve. Fix the placement, then solve again.
- A session denial. The request is fine but your identity is not: a banned IP (
t=bvis the cleanest signal), a refused range (fresh addresses from the same provider fail too — a proxy-class problem, not a captcha one), or a blocked account (logged-in requests fail while anonymous ones pass; a new IP will not help). Each has its own fix: rotate the IP, change the class, or stop and look at what the account did. - A rate limit or a content block. A 429 with
Retry-Afterwants waiting, not solving. A 200 with wrong content wants comparison against a known-good page, because your check — not the target — is probably misreading the result.
When a challenge loop follows a solve — you replay and get challenged again — the replay broke the consistency contract: the IP or user agent differs from the solve, the proxy rotated, or the client's presentation differs from a browser (headers and user agents). The Cloudflare guide also notes a cf_clearance can expire or be revoked on the site's own schedule, so a challenge after a working stretch is not always your mistake. Akamai's _abck shows the same pattern (Akamai solver API).
Back off and set a retry budget
Retrying is where scrapers burn money and goodwill. Set four limits before you write the loop:
- Attempts per URL. A hard cap, so one stubborn URL cannot run forever.
- Solves per URL and identity. A solve is a charged task, and a task that finishes as failed automatically returns its original charge once. Costs covers the arithmetic.
- Waits with jitter. Doubling delays, randomised between zero and the ceiling, so parallel workers do not retry in step.
- A circuit breaker. When the block rate crosses a threshold, pause the job instead of pushing harder.
SurSolver has its own limit, separate from the target's. Each account has a thread limit: the number of tasks that can be open (queued or processing) at the same time. A refused submission answers ERROR_NO_SLOT_AVAILABLE, creates no task and charges nothing. See Rate limits.
The starting values below are placeholders, not benchmarks. Tune them to your own traffic. The code classifies a response, decides the next step and runs the loop. You pass in your own get, solve and rotate functions, so it works with any HTTP client and any solving helper:
import random
import time
from collections import deque
CHALLENGE_MARKERS = {
'cloudflare-challenge': 'Just a moment',
'datadome': 'captcha-delivery.com',
'akamai': 'Pardon Our Interruption',
}
# Text a target prints when a token arrived and the application refused it.
# Fill this from your target's rejected submission — one string is enough.
APP_REJECTION_MARKERS = ('invalid captcha', 'captcha is incorrect')
STATUS_ERROR_FLOOR = 400
STATUS_RATE_LIMITED = 429
STATUS_FORBIDDEN = 403
MAX_ATTEMPTS = 4
MAX_SOLVES_PER_IDENTITY = 1
MAX_VERIFICATION_FAILURES = 2
BACKOFF_BASE_SECONDS = 2.0
BACKOFF_CAP_SECONDS = 60.0
RETRY_AFTER_JITTER_SECONDS = 1.0
MONITOR_WINDOW = 50
MONITOR_THRESHOLD = 0.2
class BlockRateExceeded(RuntimeError):
pass
def classify(status: int, body: str) -> str:
if status >= STATUS_ERROR_FLOOR:
for name, marker in CHALLENGE_MARKERS.items():
if marker in body:
return f'challenge:{name}'
if status == STATUS_RATE_LIMITED:
return 'rate-limited'
if status == STATUS_FORBIDDEN:
return 'denied'
if any(marker in body for marker in APP_REJECTION_MARKERS):
# HTTP 200 but the application refused the token: a delivery fault,
# not a solve fault. Treat it separately from a fresh challenge.
return 'verification'
return 'ok'
def backoff_delay(attempt: int, retry_after: float | None = None) -> float:
if retry_after is not None:
return retry_after + random.uniform(0, RETRY_AFTER_JITTER_SECONDS)
ceiling = min(BACKOFF_CAP_SECONDS, BACKOFF_BASE_SECONDS * 2**attempt)
return random.uniform(0, ceiling)
def retry_after_seconds(headers) -> float | None:
value = headers.get('Retry-After', '')
return float(value) if value.isdigit() else None
def next_step(kind: str, solves_used: int) -> str:
if kind == 'ok':
return 'done'
if kind == 'rate-limited':
return 'wait'
if kind.startswith('challenge:') and solves_used < MAX_SOLVES_PER_IDENTITY:
return 'solve'
return 'rotate'
class BlockMonitor:
def __init__(self) -> None:
self.recent: deque[bool] = deque(maxlen=MONITOR_WINDOW)
def record(self, kind: str) -> None:
self.recent.append(kind != 'ok')
def tripped(self) -> bool:
if len(self.recent) < MONITOR_WINDOW:
return False
return sum(self.recent) / MONITOR_WINDOW > MONITOR_THRESHOLD
def fetch(url, get, solve, rotate, monitor: BlockMonitor):
solves_used = 0
verification_failures = 0
for attempt in range(MAX_ATTEMPTS):
if monitor.tripped():
raise BlockRateExceeded('block rate above threshold: pause the job')
response = get(url)
kind = classify(response.status_code, response.text)
monitor.record(kind)
step = next_step(kind, solves_used)
if step == 'done':
return response
if step == 'wait':
time.sleep(backoff_delay(attempt, retry_after_seconds(response.headers)))
elif step == 'solve':
solve(url, kind)
solves_used += 1
elif kind == 'verification':
# A refused token is a delivery fault. Check the field name, the
# callback and the one-submit rule before paying for another solve.
verification_failures += 1
if verification_failures > MAX_VERIFICATION_FAILURES:
raise RuntimeError(
f'{url}: application keeps refusing the token; '
'check the submit placement, not the solve'
)
rotate()
solves_used = 0
time.sleep(backoff_delay(attempt))
else:
rotate()
solves_used = 0
time.sleep(backoff_delay(attempt))
raise RuntimeError(f'{url}: still blocked after {MAX_ATTEMPTS} attempts')
Your solve is a createTask and getTaskResult helper like the one in the Python integration guide. It must also apply the result to the session get uses, with the same proxy and user agent.
Rotate or persist
Treat identity as one bundle: exit IP, user agent, language and cookies. Keep the bundle while it works. The types that require your proxy expect the result replayed from the solve's exit with its user agent, so the cookies and the proxy belong together: change one, and the other starts from zero.
Rotate the bundle as a unit when it stops working: new IP, new cookies, same rules for user agent and language, then a fresh session. Do not carry a cookie across to another IP.
Do not rotate on every request for the cookie-based types. A rotating gateway breaks the "same exit" rule these types rely on. Hold one sticky session per identity, as described in proxies for captcha solving.
Monitor the block rate
You cannot tune what you do not measure. For every request, log the target host, the proxy or session id, the status, the classification above and the number of solves used. Compute the share of non-ok responses over a sliding window, per target and per proxy pool.
A rising rate has an order of causes worth checking:
- Your request pattern: too fast, too regular, too many parallel workers on one IP.
- Identity consistency: any piece of the bundle changing mid-session.
- The proxy class, if one pool is worse than the rest.
- A rising share of
verificationclassifications: your submit placement broke, not the solve.
Watch the money alongside. POST /getBalance reports the cash balance, and a block-heavy run shows up there before it shows up in your logs.
Log one day first
Start by logging the classification of every response for a day, without changing anything else — most scrapers discover their "blocks" were half verification failures and 429s. Then add the retry budget and the circuit breaker, and open Errors to see how each task failure reaches you. When a genuine challenge is the cause, pick the matching solver page — Cloudflare Challenge, DataDome, Akamai or AWS WAF Challenge — and send a createTask for that one type.