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
- Enable
anti_captcha
in your browser profile settings - Use quality proxies to minimize Turnstile challenges
Solving Methods
Method 1: Simple Manual Solving (Recommended)
The easiest way to handle Turnstile - detect and solve when needed:
- Python
- JavaScript
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())
const { chromium } = require('playwright');
async function solveTurnstileSimple() {
// Connect to your Surfsky browser
const browser = await chromium.connectOverCDP('ws://your-browser-url');
const page = await browser.newPage();
// Create CDP session
const client = await page.context().newCDPSession(page);
// Navigate to page with Turnstile
await page.goto('https://example.com/protected');
// Check if Turnstile is present
const turnstileElement = await page.$('.cf-turnstile, iframe[src*="turnstile"]');
if (turnstileElement) {
console.log('Turnstile detected, solving...');
// Solve Turnstile
const response = await client.send('Captcha.solve', { type: 'turnstile' });
if (response.status === 'success') {
console.log('✓ Turnstile solved!');
// Continue with your automation
await page.waitForLoadState('networkidle');
} else {
console.log('✗ Failed to solve Turnstile');
}
}
await browser.close();
}
solveTurnstileSimple().catch(console.error);
Method 2: Auto Solving
Let the browser automatically detect and solve Turnstile challenges:
- Python
- JavaScript
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())
const { chromium } = require('playwright');
async function solveTurnstileAuto() {
const browser = await chromium.connectOverCDP('ws://your-browser-url');
const page = await browser.newPage();
const client = await page.context().newCDPSession(page);
// Enable auto-solving for Turnstile
await client.send('Captcha.autoSolve', { type: 'turnstile' });
console.log('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();
}
solveTurnstileAuto().catch(console.error);
Best Practices
- Use Auto Mode for seamless automation
- Quality Proxies significantly reduce Turnstile frequency
- Human Emulation helps avoid triggering Turnstile
- 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].