CfSolver
Cloudflare Turnstile detection and bypass utilities for Python web automation.
cfsolver provides a small helper package for locating Cloudflare Turnstile challenges and computing checkbox coordinates using either patchright or pydoll automation backends.
Features
- Detect Cloudflare Turnstile challenges on a page
- Resolve Turnstile iframe coordinates through open shadow roots, closed shadow roots, and CDP DOM inspection
- Click the checkbox automatically using Patchright or Pydoll
- Support for both Playwright-style
patchrightand CDP-nativepydoll
Requirements
- Python 3.10+
patchright>=1.61.2pydoll-python>=2.23.1- A Chromium browser binary installed and reachable from your system
Installation
python -m pip install -e .
Or install package dependencies manually:
python -m pip install patchright>=1.61.2 pydoll-python>=2.23.1
Quick Start
Import the exported solver class from the package root:
from cfsolver import CfSolver
Patchright Example
import asyncio
from patchright.async_api import async_playwright
from cfsolver import CfSolver
async def main():
async with async_playwright() as p:
browser = await p.chromium.launch(
executable_path="/usr/bin/chromium",
headless=False,
)
page = await browser.new_page()
await page.goto("https://2captcha.com/demo/cloudflare-turnstile")
success = await CfSolver.expectAndBypass(page, backend="patchright")
print("Bypass successful" if success else "Bypass failed")
await browser.close()
if __name__ == "__main__":
asyncio.run(main())
Pydoll Example
import asyncio
from pydoll.browser.chromium import Chrome
from pydoll.browser.options import ChromiumOptions
from cfsolver import CfSolver
async def main():
options = ChromiumOptions()
options.binary_location = "/usr/bin/chromium"
async with Chrome(options=options) as browser:
tab = await browser.start()
await tab.go_to("https://2captcha.com/demo/cloudflare-turnstile")
success = await CfSolver.expectAndBypass(page=tab, backend="pydoll")
print("Bypass successful" if success else "Bypass failed")
await asyncio.sleep(5)
if __name__ == "__main__":
asyncio.run(main())
API
CfSolver.expectAndBypass(page, backend="patchright", wait_seconds=5, max_attempts=10)
Automatically detects a Cloudflare Turnstile challenge on the given page and attempts to click the checkbox until the page is bypassed or the attempt limit is reached.
Parameters:
page: a Patchright or Pydoll page/tab objectbackend:"patchright"or"pydoll"wait_seconds: seconds to wait after each clickmax_attempts: maximum number of bypass attempts
Returns:
Trueif bypass succeededFalseotherwise
CfSolver.is_challenge_present(page, backend="patchright")
Returns True if a Cloudflare Turnstile challenge is present on the page.
CfSolver.get_coords_if_challenge(page, backend="patchright")
Returns a coordinate dictionary if a challenge is present, otherwise returns None.
Returned dictionary keys:
foundx,ywidth,heightcheckbox_x,checkbox_ysrc
Example scripts
The repository includes ready-to-run examples in src/cfsolver/examples/:
get_cord_demo.py— detect a challenge and print/click checkbox coordinatespatchright_turnstile_demo.py— Patchright demo for a Turnstile challenge pagepatchright_ahrefs_humanizer.py— Patchright example that enters text on Ahrefs and bypasses Turnstilepatchright_zoominfo_ex.py— Patchright example for ZoomInfo page automationpydoll_turnstile_demo.py— Pydoll demo for a Turnstile challenge pagepydoll_ahrefs_humanizer.py— Pydoll example that enters text and bypasses Turnstilepydoll_zoominfo_ex.py— Pydoll example for ZoomInfo page automation
Run an example with:
python src/cfsolver/examples/patchright_turnstile_demo.py
Notes
CfSolveruses CDP-based DOM inspection to locate Turnstile iframes inside shadow roots.- The example scripts assume Chromium is available at
/usr/bin/chromium. Adjustexecutable_pathorbinary_locationif needed. - This package is designed for automation and experimentation only.
License
MIT
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cfsolver_python-0.1.2.tar.gz.
File metadata
- Download URL: cfsolver_python-0.1.2.tar.gz
- Upload date:
- Size: 11.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3cd6ec54d2c157538d9a562c85bed8d13ebc3c55513737019ac7fe8c4a566dca
|
|
| MD5 |
2d9e606d0a3d765f3286a5996fb78e0f
|
|
| BLAKE2b-256 |
061d4c9aa36480855e0080604d5e0a36bbc1c9073798d15cd0bf823b65a9d58d
|
Provenance
The following attestation bundles were made for cfsolver_python-0.1.2.tar.gz:
Publisher:
publish.yml on dx-bear/cfsolver
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cfsolver_python-0.1.2.tar.gz -
Subject digest:
3cd6ec54d2c157538d9a562c85bed8d13ebc3c55513737019ac7fe8c4a566dca - Sigstore transparency entry: 2430822020
- Sigstore integration time:
-
Permalink:
dx-bear/cfsolver@2e19494d824138b343e1863bc187b6a3cb5b2748 -
Branch / Tag:
refs/tags/0.1.2 - Owner: https://github.com/dx-bear
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2e19494d824138b343e1863bc187b6a3cb5b2748 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file cfsolver_python-0.1.2-py3-none-any.whl.
File metadata
- Download URL: cfsolver_python-0.1.2-py3-none-any.whl
- Upload date:
- Size: 16.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
847bbdc32a4d542dd4f8dd2a313489b71627559f92f5b2e11f8c5cf23bb7c876
|
|
| MD5 |
197fc17ce7d2414607dc6dba29e3f151
|
|
| BLAKE2b-256 |
cd2c1434137cde57efa3b635775bc4649f522e081dae8ad7e17aaa0c74d757b8
|
Provenance
The following attestation bundles were made for cfsolver_python-0.1.2-py3-none-any.whl:
Publisher:
publish.yml on dx-bear/cfsolver
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cfsolver_python-0.1.2-py3-none-any.whl -
Subject digest:
847bbdc32a4d542dd4f8dd2a313489b71627559f92f5b2e11f8c5cf23bb7c876 - Sigstore transparency entry: 2430822340
- Sigstore integration time:
-
Permalink:
dx-bear/cfsolver@2e19494d824138b343e1863bc187b6a3cb5b2748 -
Branch / Tag:
refs/tags/0.1.2 - Owner: https://github.com/dx-bear
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2e19494d824138b343e1863bc187b6a3cb5b2748 -
Trigger Event:
workflow_dispatch
-
Statement type: