Skip to content

Add support for Cloudflare Turnstile CAPTCHA solving#134

Open
ad-m wants to merge 1 commit intomasterfrom
claude/modernize-library-plan-dXUsJ
Open

Add support for Cloudflare Turnstile CAPTCHA solving#134
ad-m wants to merge 1 commit intomasterfrom
claude/modernize-library-plan-dXUsJ

Conversation

@ad-m
Copy link
Owner

@ad-m ad-m commented Mar 8, 2026

Summary

This PR adds support for solving Cloudflare Turnstile CAPTCHA challenges to the python-anticaptcha library. Two new task classes are introduced to handle both proxy-less and proxy-based solving approaches.

Key Changes

  • New Task Classes: Added TurnstileTaskProxyless and TurnstileTask classes

    • TurnstileTaskProxyless: Solves Turnstile without a proxy, requiring only website URL and site key
    • TurnstileTask: Extends the proxyless version with proxy, user-agent, and cookie support for proxy-based solving
  • Optional Parameters: Both classes support optional Turnstile-specific parameters:

    • action: Action parameter passed to the Turnstile widget
    • cdata: cData token for Cloudflare-protected pages
    • chl_page_data: chlPageData token for Cloudflare pages
  • Documentation & Examples:

    • Updated README.md and docs/usage.rst with Turnstile usage examples
    • Added three example scripts demonstrating integration:
      • sync_turnstile_request.py: Synchronous proxyless example
      • sync_turnstile_request_proxy.py: Synchronous proxy-based example
      • async_turnstile_request.py: Asynchronous proxyless example
  • API Exports: Updated __init__.py to export the new task classes

  • Test Coverage: Added comprehensive test cases for both task classes covering required fields, optional fields, and proxy integration

Implementation Details

  • TurnstileTaskProxyless follows the existing pattern of other proxyless task classes (e.g., RecaptchaV3TaskProxyless)
  • TurnstileTask uses multiple inheritance with ProxyMixin, UserAgentMixin, and CookieMixin to reuse proxy handling logic
  • Optional parameters are only included in serialized output when explicitly provided (not None)
  • The implementation automatically detects all Turnstile subtypes (manual, non-interactive, invisible)

https://claude.ai/code/session_01KKZjR7gkNfk4vUhJb1eJr6

Add TurnstileTaskProxyless and TurnstileTask classes for solving
Cloudflare Turnstile challenges, with optional action, cData, and
chlPageData parameters. Includes sync/async examples, unit tests,
and documentation updates.

https://claude.ai/code/session_01KKZjR7gkNfk4vUhJb1eJr6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants