biusberline/cloudflare-turnstile-solver

A small Python library and CLI for working with Cloudflare Turnstile on your own pages - read the sitekey, build the token, verify the result.

What it solves

It simplifies the process of bypassing Cloudflare Turnstile widgets and the "5s challenge" for automated scripts, CI pipelines, and QA automation. It removes the need for a browser or webdriver to obtain the required cf-turnstile-response token.

How it works

The library scans a target webpage's HTML to find the Turnstile data-sitekey and optional data-action. It then submits a solve task to the Peak API, which generates a valid token for that specific sitekey and URL. This token can then be injected into a form or HTTP request to bypass the security check.

Who it’s for

Developers, integration engineers, and QA automation specialists who need to automate interactions with websites protected by Cloudflare Turnstile without managing a browser environment.

Highlights

  • Browser-less operation: Runs on the standard Python library without requiring a browser, Node.js, or webdrivers.
  • Integrated workflow: Provides a single function (token_for_page) to handle both sitekey discovery and token generation.
  • CIL support: Includes a command-line interface for use in shell scripts and CI runners.
  • Proxy support: Allows the use of proxies to ensure the token is bound to the same environment as the request.
  • Automatic retries: The create_token function automatically handles transient failures.

Related

  • Project
  • Project
  • Project
  • Project