Skip to main content

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 patchright and CDP-native pydoll

Requirements

  • Python 3.10+
  • patchright>=1.61.2
  • pydoll-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 object
  • backend: "patchright" or "pydoll"
  • wait_seconds: seconds to wait after each click
  • max_attempts: maximum number of bypass attempts

Returns:

  • True if bypass succeeded
  • False otherwise

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:

  • found
  • x, y
  • width, height
  • checkbox_x, checkbox_y
  • src

Example scripts

The repository includes ready-to-run examples in src/cfsolver/examples/:

  • get_cord_demo.py — detect a challenge and print/click checkbox coordinates
  • patchright_turnstile_demo.py — Patchright demo for a Turnstile challenge page
  • patchright_ahrefs_humanizer.py — Patchright example that enters text on Ahrefs and bypasses Turnstile
  • patchright_zoominfo_ex.py — Patchright example for ZoomInfo page automation
  • pydoll_turnstile_demo.py — Pydoll demo for a Turnstile challenge page
  • pydoll_ahrefs_humanizer.py — Pydoll example that enters text and bypasses Turnstile
  • pydoll_zoominfo_ex.py — Pydoll example for ZoomInfo page automation

Run an example with:

python src/cfsolver/examples/patchright_turnstile_demo.py

Notes

  • CfSolver uses CDP-based DOM inspection to locate Turnstile iframes inside shadow roots.
  • The example scripts assume Chromium is available at /usr/bin/chromium. Adjust executable_path or binary_location if 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

cfsolver_python-0.1.2.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

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

cfsolver_python-0.1.2-py3-none-any.whl (16.2 kB view details)

Uploaded Python 3

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

Hashes for cfsolver_python-0.1.2.tar.gz
Algorithm Hash digest
SHA256 3cd6ec54d2c157538d9a562c85bed8d13ebc3c55513737019ac7fe8c4a566dca
MD5 2d9e606d0a3d765f3286a5996fb78e0f
BLAKE2b-256 061d4c9aa36480855e0080604d5e0a36bbc1c9073798d15cd0bf823b65a9d58d

See more details on using hashes here.

Provenance

The following attestation bundles were made for cfsolver_python-0.1.2.tar.gz:

Publisher: publish.yml on dx-bear/cfsolver

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for cfsolver_python-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 847bbdc32a4d542dd4f8dd2a313489b71627559f92f5b2e11f8c5cf23bb7c876
MD5 197fc17ce7d2414607dc6dba29e3f151
BLAKE2b-256 cd2c1434137cde57efa3b635775bc4649f522e081dae8ad7e17aaa0c74d757b8

See more details on using hashes here.

Provenance

The following attestation bundles were made for cfsolver_python-0.1.2-py3-none-any.whl:

Publisher: publish.yml on dx-bear/cfsolver

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page