Skip to main content

Cloudflare Turnstile Solver

PyPI CI

Get past a Cloudflare Turnstile challenge once, then scrape with curl_cffi.

Note: intended for accessing sites you are allowed to access programmatically.

Installation

# uv
uv add cfts-solver

# pip
pip install cfts-solver

You also need Google Chrome or Chromium on the host. It runs once per host, to clear the challenge; every request after that is plain HTTP.

Use

import cfts_solver
from curl_cffi import requests

URL = "https://example.com/"

session = requests.Session(impersonate="chrome")
res = session.get(URL)

if cfts_solver.is_challenged(res.headers, res.text):
    clearance = cfts_solver.solve_challenge(URL)
    clearance.apply(session)  # cookies plus the user agent that earned them
    res = session.get(URL)

print(res.status_code, len(res.text))
from cfts_solver import TurnstileSession

with TurnstileSession() as session:
    res = session.get("https://example.com/")
    print(res.status_code)
from cfts_solver import TurnstileSolver

solver = TurnstileSolver()
clearance = solver.solve("https://example.com/")
refreshed = solver.solve("https://example.com/", refresh=True)

print(clearance.token, clearance.user_agent)

Clearances are cached under $XDG_CACHE_HOME/cfts-solver/, keyed by host and proxy, so a second process does not start a second browser. Pass ClearanceStore.in_memory() to keep nothing, or ClearanceStore(path) to keep it somewhere else.

License

MIT License

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cfts_solver-0.0.0.tar.gz (16.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cfts_solver-0.0.0-py3-none-any.whl (20.3 kB view details)

Uploaded Python 3

File details

Details for the file cfts_solver-0.0.0.tar.gz.

File metadata

  • Download URL: cfts_solver-0.0.0.tar.gz
  • Upload date:
  • Size: 16.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for cfts_solver-0.0.0.tar.gz
Algorithm Hash digest
SHA256 3c4e40be36762e299159fb657c58f2f74d2f03d0e98c3288e01b7c4529dcf783
MD5 d3524d9dad84f64893d002a8211203b7
BLAKE2b-256 24323e537f2c49099480eb31c07c733a4fdd05f0a147b911d6bacd929cd83d1d

See more details on using hashes here.

File details

Details for the file cfts_solver-0.0.0-py3-none-any.whl.

File metadata

  • Download URL: cfts_solver-0.0.0-py3-none-any.whl
  • Upload date:
  • Size: 20.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for cfts_solver-0.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 00fe4c0931cbb07f108a9a75f9016177e055e249af0d0c556120ae22b2583fd3
MD5 0b7bd48048e3e34bb73fa7ec0bb96eb3
BLAKE2b-256 875bba3ca0166c5608e3dbd7e6e03a7ac699bf5ea5d22f854e39c3b9abb41064

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.0.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page