cloudflare-skip
Skip Cloudflare challenges: solve once in headless Chrome, then reuse the clearance with fast HTTP requests. No display needed.
Quick start
pip install cloudflare-skip
cloudflare-skip https://cl-skip.tn3w.dev # non-interactive challenge
cloudflare-skip https://cl-skip.tn3w.dev/interactive # interactive (checkbox) challenge
cloudflare-skip --turnstile https://cl-skip.tn3w.dev/turnstile # print a widget token
from cloudflare_skip import get, solve, solve_turnstile
response = get("https://cl-skip.tn3w.dev", params={"q": "x"}, timeout=10)
print(response.status_code, response.text)
clearance = solve("https://cl-skip.tn3w.dev") # {"cookies": {...}, "user_agent": "..."}
token = solve_turnstile("https://cl-skip.tn3w.dev/turnstile") # cf-turnstile-response
get(url, **kwargs) returns a curl_cffi response; keyword arguments (params,
headers, cookies, timeout, ...) go to curl_cffi. It raises ChallengeError if
Cloudflare still challenges after a solve and TimeoutError if the browser cannot solve
within 30s. The CLI prints the body, writes the status to stderr and exits 1 on 4xx/5xx.
Turnstile widgets in your own flows
Sites that embed Turnstile themselves answer 200 without cf-mitigated, so get
can't see it. Get a token with solve_turnstile and send it where the site's own
JavaScript would (form field, JSON body or header; check the browser's network tab):
from cloudflare_skip import session, solve_turnstile
token = solve_turnstile("https://cl-skip.tn3w.dev/turnstile")
response = session.post(
"https://cl-skip.tn3w.dev/turnstile/verify", data={"cf-turnstile-response": token}
)
If the widget only appears after a click (turnstile.render(...) in the site's
script), pass its sitekey and the widget is rendered on that page directly, no click
needed. Extra keyword arguments (action, cData, ...) go to turnstile.render; copy
them from the site's call, since the server may check action:
token = solve_turnstile("https://example.com/watch", sitekey="0x4AAAA...", action="play")
cloudflare-skip --sitekey 0x4AAAA... --action play https://example.com/watch
Tokens are single-use and expire after 300s, so get one right before each request.
Needs Chrome or Chromium (found on PATH, or set CHROME_PATH). Runs headless, so it
works on servers without a display; solve(url, headless=False) shows the window.
As root (e.g. in Docker) the sandbox is disabled automatically.
How it works
- Request with
curl_cffi(Chrome TLS fingerprint) and the cached clearance. cf-mitigated: challenge→ headless Chrome opens the page, driven over the DevTools protocol directly (no automation framework).- Interactive Turnstile: once its checkbox renders (found through the frame's DOM,
closed shadow roots included), it is focused and ticked with
Space. - As soon as
cf_clearanceis set, cookies + user agent are cached per host in~/.cache/cloudflare_skip.jsonand replayed over HTTP. - Turnstile widgets on normal pages:
solve_turnstileticks the same way and returns thecf-turnstile-responsetoken as soon as it is filled. With a sitekey it renders its own widget on the page (loading Turnstile's script if missing) instead.
| Run | Time |
|---|---|
First, browser solve (non-interactive, /) |
~2.7-3.1s |
First, browser solve (interactive, /interactive) |
~3.2-3.9s |
Turnstile widget token (/turnstile) |
~2.3-2.8s |
| Cached, in-process | ~0.02-0.1s |
Almost all of the solve time is Cloudflare itself: Chrome is ready after 0.2s, the challenge loads at ~0.8s, the rest is Cloudflare's check (and showing the checkbox).
Notes
- The API is synchronous; from async code use
await asyncio.to_thread(get, url). - A clearance is bound to the user agent and IP of the solving browser:
getalways sends the browser's user agent, and a proxy passed inkwargsmakes the replay fail withChallengeError. The cache holds session cookies, so it is created with mode 600.
Things Cloudflare detects, found the hard way:
--remote-debugging-port=0and--remote-debugging-pipe: the clearance is issued but rejected on the next request, so the page reloads forever. A fixed free port works.- The
HeadlessChromeuser agent. It is replaced with--user-agent(the reduced UA of headful Chrome, major version fromchrome --version); a CDP user agent override breaks client hints and gets flagged too. - CDP mouse clicks on Turnstile are always rejected; keyboard input passes.
- Attaching to the Turnstile frame on every poll; it is attached once and reused.
Datacenter IPs and containers pass (tested on GitHub's Azure runners: Ubuntu 22.04 and 24.04, headless and Xvfb, Docker as root). What broke there was the environment:
- Ubuntu 23.10+ and many containers block the user namespaces Chrome's sandbox needs,
so Chrome aborts with "No usable sandbox!". It is then restarted with
--no-sandbox. - Reading the Turnstile frame's DOM on every 20ms poll starves small VMs; the checkbox is looked up every 250ms instead, the token and cookies are still polled every 20ms.
- The first Chrome start on a fresh machine can take 20s; later ones take about 1s.
Development
uv run pytest
uv run scripts/record.py <non-interactive|interactive> [light|dark] # header GIFs
site/ is the test page behind https://cl-skip.tn3w.dev, put behind Cloudflare
challenge rules: / gets a non-interactive challenge, /interactive an interactive
one. /turnstile is a standalone managed Turnstile widget (no challenge rule), its
token verified server side at /turnstile/verify. pages.yml packs site/ as the
github-pages artifact on every push to it; the site's own server deploys that.
scripts/record.py screencasts headless Chrome solving the challenge and encodes the
frames with gifski (needs gifski, no display).
Metadata
Release files for cloudflare-skip 2.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cloudflare_skip-2.1.1.tar.gz | 13.9 kB | With provenance | Details for cloudflare_skip-2.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cloudflare_skip-2.1.1-py3-none-any.whl | Python 3 | none | any | Details for cloudflare_skip-2.1.1-py3-none-any.whl |
Total release size: 27.7 kB
Release files / cloudflare_skip-2.1.1.tar.gz
| Download URL | cloudflare_skip-2.1.1.tar.gz |
|---|---|
| Size | 13.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
57b00b5ade34be606a0dbf120022c01eb196cb46594c0590e7be83e92227472d
|
|
BLAKE2b-256 checksum How to use checksums |
801a8ba745dde94dc296753343f94263958308e6fb2765ca66c98107a0d0becc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.
Transparency logRelease files / cloudflare_skip-2.1.1-py3-none-any.whl
| Download URL | cloudflare_skip-2.1.1-py3-none-any.whl |
|---|---|
| Size | 13.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9037c1718959fdceba88d5761735f9537f7bd9d223f8fff033322151f8e0db7c
|
|
BLAKE2b-256 checksum How to use checksums |
800262da1faa46d6eacac3486fb2040ddbd23363c971818bc64592e7f416b139
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.
Transparency logSecurity for cloudflare-skip 2.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for cloudflare_skip-2.1.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.