Why your scraper gets a 403 on Cloudflare Turnstile (and the token-injection fix)
Description and use
Scrapers hitting Cloudflare Turnstile 403s can obtain a valid token from a residential IP (via browser or solving API) and inject it into requests, bypassing the block.
Problem
Scrapers hit 403 errors or endless Turnstile challenges when accessing sites protected by Cloudflare Turnstile, despite working HTML requests.
Outcome
Scrapers can reliably bypass Cloudflare Turnstile 403s by generating a valid token from a residential IP and injecting it into their requests, reducing reliance on full browser sessions and improving throughput.
Workflow
- 1. Inspect target page to locate the Turnstile sitekey (data-sitekey attribute or JS render call).
- 2. Obtain a Turnstile token: either run a real browser (Playwright/Selenium) through a residential proxy and read the cf-turnstile-response value, or call a solving API with the target URL and sitekey.
- 3. If using a solving API, send a POST to the API endpoint with API key, task_type, url, and sitekey; receive the token in the response.
- 4. Attach the token to the scraper’s HTTP request payload (e.g., as cf-turnstile-response) and submit before the token expires (~300 s).
- 5. Handle common failure cases: ensure token is fresh, single-use, correct sitekey, and matching solving IP if required.
- 6. If token alone fails, consider full browser session with proper fingerprint and session cookies.
- 7. Monitor for changes in Turnstile challenge variants and update browser or API usage accordingly.
Evidence
Cloudflare Turnstile scores the browser, and separately Cloudflare scores the connection. A 403 usually means you failed one of these: Fingerprint… IP reputation.
The widget produces a token — cf-turnstile-response — and on most deployments that token is validated server‑side against the sitekey and the hostname, not against the IP that produced it.
Call a solving API. You hand it the URL and sitekey; it runs the browser farm on residential IPs and hands back a token.
- Record date: 2026-09-14T19:00:44.301Z