ProductsIntegrationsResourcesDocumentationPricing
Start Now

© 2026 CapSolver. All rights reserved.

CONTACT US

Slack: lola@capsolver.com

Products

  • reCAPTCHA v2
  • reCAPTCHA v3
  • Cloudflare Turnstile
  • Cloudflare Challenge
  • AWS WAF
  • Browser Extension
  • Many more CAPTCHA types

Integrations

  • Selenium
  • Playwright
  • Puppeteer
  • n8n
  • Partners
  • View All Integrations

Resources

  • Referral System
  • Documentation
  • API Reference
  • Blog
  • FAQs
  • Glossary
  • Status

Legal

  • Terms & Conditions
  • Privacy Policy
  • Refund Policy
  • Don't Sell My Info
Blog/Cloudflare/How to solve Cloudflare Turnstile Captcha with Python
May13, 2024

How to solve Cloudflare Turnstile Captcha with Python

Sora Fujimoto

Sora Fujimoto

AI Solutions Architect

What is Cloudflare Turnstile

Cloudflare Turnstile is a free tool designed to replace traditional CAPTCHAs. Turnstile provides frustration-free, CAPTCHA-free web experiences for visitors with just a simple snippet of code. Unlike traditional CAPTCHAs, it protects websites from bot traffic without compromising user privacy or user experience.

Key Benefits of Turnstile:

  • User-friendly: no more annoying puzzles or image selections.
  • Privacy-first: does not track personal data.
  • Anti-bot protection: ensures visitors are real and mitigates abuse.
  • Lightweight and easy to implement with minimal code.

How to Identify Cloudflare Turnstile Captchas

Turnstile can appear in different forms depending on the context and risk assessment:

  1. Non-interactive challenge

    • No interaction is required from the user.
      Example
      Example link
  2. Non-intrusive interactive challenge

    • A simple click may be required if the visitor is suspected to be a bot.
      Interactive Example
      Example link
  3. Invisible challenge

    • The captcha is loaded in the HTML but not visible on the page.
      Invisible Example
      Example link

🛠️ Solving Cloudflare Turnstile Captcha with Python

⚙️ Prerequisites

  • Python installed (Download Python)
  • CapSolver API Key

🤖 Step 1: Install Required Packages

bash Copy
pip install requests

👨‍💻 Step 2: Python Script to Solve Turnstile

python Copy
import time
import requests

CAPSOLVER_API_KEY = "api key"
PAGE_URL = "url"
WEBSITE_KEY = "site key"

def solvecf(metadata_action=None, metadata_cdata=None):
    url = "https://api.capsolver.com/createTask"
    task = {
        "type": "AntiTurnstileTaskProxyLess",
        "websiteURL": PAGE_URL,
        "websiteKey": WEBSITE_KEY,
    }
    if metadata_action or metadata_cdata:
        task["metadata"] = {}
        if metadata_action:
            task["metadata"]["action"] = metadata_action
        if metadata_cdata:
            task["metadata"]["cdata"] = metadata_cdata
    data = {
        "clientKey": CAPSOLVER_API_KEY,
        "task": task
    }
    response_data = requests.post(url, json=data).json()
    print(response_data)
    return response_data['taskId']


def solutionGet(taskId):
    url = "https://api.capsolver.com/getTaskResult"
    status = ""
    while status != "ready":
        data = {"clientKey": CAPSOLVER_API_KEY, "taskId": taskId}
        response_data = requests.post(url, json=data).json()
        print(response_data)
        status = response_data.get('status', '')
        print(status)
        if status == "ready":
            return response_data['solution']

        time.sleep(2)


def main():
    
    taskId = solvecf()
    solution = solutionGet(taskId)
    if solution:
        user_agent = solution['userAgent']
        token = solution['token']

    print("User_Agent:", user_agent)
    print("Solved Turnstile Captcha, token:", token)

  
if __name__ == "__main__":
    main()

⚠️ Variables to Update

  • CAPSOLVER_API_KEY: Get your API key from the Capsolver Dashboard.
  • PAGE_URL: Replace with the URL of the website where you want to solve Turnstile.
  • WEBSITE_KEY: Replace with the Turnstile site key of the website.

✅ Conclusion

By leveraging CapSolver, developers can efficiently bypass Cloudflare Turnstile CAPTCHAs in a secure and automated way. With high accuracy, proxyless support, and minimal setup, this solution is ideal for web scraping, automation, and testing workflows that need to interact with sites protected by Turnstile.

Capsolver’s Python API makes it straightforward to integrate into existing scripts or automation pipelines, allowing you to save time and reduce manual intervention.


❓ FAQ

Q1: Do I need proxies to use Capsolver for Turnstile?
A: No, Capsolver provides proxyless solving, though you can use your own proxies for additional safety if needed.

Q2: How long does it take to solve a Turnstile captcha?
A: Usually a few seconds, depending on the challenge type and network conditions.

Q3: Can this solution handle multiple Turnstile challenges in parallel?
A: Yes, you can create multiple tasks simultaneously to solve challenges concurrently.

Q4: Is it safe to use for production environments?
A: Yes, Capsolver is designed for high reliability and can handle real-time automated workflows without risk to your accounts.

Q5: Are there limitations for the invisible Turnstile challenge?
A: Invisible challenges work the same way as visible ones; Capsolver detects and solves them automatically.

More

CloudflareApr 21, 2026

Cloudflare Turnstile Verification Failed? Causes, Fixes & Troubleshooting Guide

Learn how to fix the "failed to verify cloudflare turnstile token" error. This guide covers causes, troubleshooting steps, and how to defeat cloudflare turnstile with CapSolver.

Emma Foster
Emma Foster
CloudflareApr 20, 2026

Best Cloudflare Challenge Solver Tools: Comparison & Use Cases

Discover the best cloudflare challenge solver tools, compare API vs. manual automation, and find optimal solutions for your web scraping and automation needs. Learn why CapSolver is a top choice.

Contents

Ethan Collins
Ethan Collins
CloudflareApr 16, 2026

How to Solve Cloudflare Turnstile in Vehicle Data Automation

Learn how to handle Cloudflare Turnstile in vehicle data and public records automation. Use CapSolver and n8n to automate record scraping efficiently.

Lucas Mitchell
Lucas Mitchell
CloudflareApr 14, 2026

CAPTCHA Error 600010: What It Means and How to Fix It Fast

Facing CAPTCHA Error 600010? Learn what this Cloudflare Turnstile error means and get step-by-step solutions for users and developers, including CapSolver integration for automation.

Anh Tuan
Anh Tuan