Skip to main content

Cloudflare Turnstile Solving

Overview

Cloudflare Turnstile is a user-friendly CAPTCHA alternative that aims to be less intrusive while maintaining security. Surfsky handles Turnstile challenges automatically, allowing your automation to proceed smoothly.

Quick Start

For most use cases, our simplified CAPTCHA solving approach handles Turnstile automatically. See our comprehensive CAPTCHA Solving Guide for full details.

Prerequisites

  1. Enable anti_captcha in your browser profile settings
  2. Use quality proxies to minimize Turnstile challenges

Solving Methods

The easiest way to handle Turnstile - detect and solve when needed:

import asyncio
from playwright.async_api import async_playwright

async def solve_turnstile_simple():
async with async_playwright() as p:
# Connect to your Surfsky browser
browser = await p.chromium.connect_over_cdp("ws://your-browser-url")
page = await browser.new_page()

# Create CDP session
client = await page.context.new_cdp_session(page)

# Navigate to page with Turnstile
await page.goto("https://example.com/protected")

# Check if Turnstile is present
if await page.query_selector(".cf-turnstile, iframe[src*='turnstile']"):
print("Turnstile detected, solving...")

# Solve Turnstile
response = await client.send("Captcha.solve", {"type": "turnstile"})

if response.get("status") == "success":
print("✓ Turnstile solved!")
# Continue with your automation
await page.wait_for_load_state("networkidle")
else:
print("✗ Failed to solve Turnstile")

await browser.close()

asyncio.run(solve_turnstile_simple())

Method 2: Auto Solving

Let the browser automatically detect and solve Turnstile challenges:

import asyncio
from playwright.async_api import async_playwright

async def solve_turnstile_auto():
async with async_playwright() as p:
browser = await p.chromium.connect_over_cdp("ws://your-browser-url")
page = await browser.new_page()
client = await page.context.new_cdp_session(page)

# Enable auto-solving for Turnstile
await client.send("Captcha.autoSolve", {"type": "turnstile"})

print("Auto-solve activated - Turnstile will be solved automatically")

# Navigate to any page - Turnstile challenges will be handled automatically
await page.goto("https://example.com/protected")

# Continue with your automation
# Any Turnstile that appears will be solved in the background

await browser.close()

asyncio.run(solve_turnstile_auto())

Best Practices

  1. Use Auto Mode for seamless automation
  2. Quality Proxies significantly reduce Turnstile frequency
  3. Human Emulation helps avoid triggering Turnstile
  4. Reuse Profiles that have successfully passed Turnstile

Need Help?

For more details on CAPTCHA solving, see our comprehensive CAPTCHA Solving Guide.

Questions? Contact us at [email protected].