🚀 Deflare
Cloudflare Turnstile detection and bypass utilities for Python web automation.
Small, focused helper utilities to locate Cloudflare Turnstile iframes (including inside closed/open shadow roots) and compute checkbox coordinates using either Patchright (Playwright-style) or Pydoll (CDP-native) backends.
| PyPI | pip install deflare |
✨ Highlights
- ✅ Detect Cloudflare Turnstile challenges automatically
- 🧭 Resolve iframe coordinates across open/closed shadow roots via CDP
- 🖱️ Click the checkbox using
page.mouse.click(Patchright) or Pydoll executor - 🔁 Retry logic and simple public API (
expectAndBypass,is_challenge_present)
📦 Requirements
- Python 3.10+
- patchright>=1.61.2 (for Patchright backend)
- pydoll-python>=2.23.1 (for Pydoll backend)
- A Chromium browser binary available on your PATH (or point to its location)
⚙️ Installation
Install from PyPI:
pip install deflare
uv add deflare
Quick Start
Import the high-level API and call the convenience method:
from deflare import Solver
# Example (Patchright):
import asyncio
from patchright.async_api import async_playwright
async def demo_patchright():
async with async_playwright() as p:
browser = await p.chromium.launch(headless=False)
page = await browser.new_page()
await page.goto("https://nopecha.com/demo/turnstile")
success = await Solver.expectAndBypass(page, backend="patchright", max_attempts=6)
print("Bypass successful" if success else "Bypass failed")
asyncio.run(demo_patchright())
Pydoll Example
import asyncio
from pydoll.browser.chromium import Chrome
from pydoll.browser.options import ChromiumOptions
from deflare import Solver
async def demo_pydoll():
options = ChromiumOptions()
options.binary_location = "/usr/bin/chromium"
async with Chrome(options=options) as browser:
tab = await browser.start()
await tab.go_to("https://nopecha.com/demo/turnstile")
success = await Solver.expectAndBypass(page=tab, backend="pydoll")
print("Bypass successful" if success else "Bypass failed")
asyncio.run(demo_pydoll())
API Overview
Solver.expectAndBypass(page, backend="patchright", wait_seconds=5, max_attempts=10)— Detects and attempts to bypass a Turnstile challenge; returnsTrueon success.Solver.is_challenge_present(page, backend="patchright")— Quick check whether a Turnstile challenge exists.Solver.get_coords_if_challenge(page, backend="patchright")— Returns coords dictionary orNone.
Returned coordinate dictionary includes keys such as found, x, y, width, height, checkbox_x, checkbox_y, and src.
Examples
See the example scripts in src/deflare/examples/ for ready-to-run demos (Patchright and Pydoll).
Run an example:
python src/deflare/examples/patchright_turnstile_demo.py
Notes
- The solver uses CDP to pierce closed shadow roots when necessary. If you rely on Patchright, ensure the chosen browser/context supports CDP sessions.
- Adjust the Chromium binary location in examples if your system uses a different path.
License
MIT
Metadata
Release files for deflare 1.0
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 |
|---|---|---|---|---|
| deflare-1.0.tar.gz | 11.3 kB | With provenance | Details for deflare-1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| deflare-1.0-py3-none-any.whl | Python 3 | none | any | Details for deflare-1.0-py3-none-any.whl |
Total release size: 27.0 kB
Release files / deflare-1.0.tar.gz
| Download URL | deflare-1.0.tar.gz |
|---|---|
| Size | 11.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fffdeeef161ebf20766b72995b01abbd11000f71d65cc4b984ec2085da99006d
|
|
BLAKE2b-256 checksum How to use checksums |
54779d8696288813666045fbdce9591c27fe6d22f09f8f13dd91d8cde5e6c672
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Sep 4, 2026.
Transparency logRelease files / deflare-1.0-py3-none-any.whl
| Download URL | deflare-1.0-py3-none-any.whl |
|---|---|
| Size | 15.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d4a1aef6cbb857d0f756050a56b40aa0ff58adcaa706f27e8f1ed30ffe78aa4a
|
|
BLAKE2b-256 checksum How to use checksums |
0f7a2e91e3c2eb47878e0017546ff6da0fa30d95ea05b6af2ae280f7231d6060
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Sep 4, 2026.
Transparency logSecurity for deflare 1.0
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 deflare-1.0.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 Sep 4, 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.