Skip to main content
Scrapling can automatically solve Cloudflare’s Turnstile challenges, including the “Just a moment…” interstitial page and interactive captchas.

Quick Start

Enable Cloudflare solving with a single parameter:
Cloudflare solving requires at least 60 seconds timeout. Scrapling automatically adjusts the timeout if you enable solve_cloudflare=True.
Source: scrapling/engines/_browsers/_validators.py:131-133

Challenge Types

Scrapling detects and solves three types of Cloudflare challenges:

Non-Interactive Challenge

The “Just a moment…” page that solves automatically:
Detection logic: scrapling/engines/_browsers/_base.py:520-533 Implementation:
Source: scrapling/engines/_browsers/_stealth.py:124-130

Managed Challenge

Interactive checkbox challenge:
Scrapling:
  1. Detects the challenge type from page content
  2. Locates the checkbox iframe
  3. Calculates precise click coordinates
  4. Clicks with human-like delay (100-200ms)
  5. Waits for network to settle
Source: scrapling/engines/_browsers/_stealth.py:132-186

Interactive Challenge

More complex interactive challenges are handled the same way:

Embedded Turnstile

Turnstile widgets embedded directly in pages:
Source: scrapling/engines/_browsers/_base.py:530-532

How It Works

Challenge Detection

Scrapling detects challenges by analyzing page content:
Source: scrapling/engines/_browsers/_base.py:502-534

Solving Process

  1. Wait for page stability - Ensure challenge is fully loaded
  2. Detect challenge type - Identify which Cloudflare challenge is present
  3. Locate challenge iframe - Find the Turnstile iframe using regex pattern
  4. Calculate click coordinates - Precise positioning with random offset
  5. Human-like interaction - Click with realistic delay
  6. Wait for resolution - Monitor page for challenge completion
  7. Retry if needed - Recursive solving for stubborn challenges
Main solver: scrapling/engines/_browsers/_stealth.py:111-186

Click Coordinate Calculation

Source: scrapling/engines/_browsers/_stealth.py:159-163

Usage Patterns

One-off Requests

Session-based Scraping

Spider Integration

Async Usage

Advanced Configuration

Custom Timeout

Some challenges take longer to solve:

With Proxy Rotation

Page Actions After Solving

Perform actions after the challenge is solved:
Note: page_action runs after Cloudflare solving completes. Source: scrapling/engines/_browsers/_stealth.py:243-252

Wait for Specific Content

Combine with selectors to wait for content after solving:

Troubleshooting

Scrapling logs challenge detection:
If no challenge is found, the page may not be protected or uses a different system.
Increase timeout for slow challenges:
The solver retries recursively:
Source: scrapling/engines/_browsers/_stealth.py:184-186
Some sites show multiple challenges. Use sessions to maintain cookies:

Limitations

  • CAPTCHA challenges - Image-based CAPTCHAs require manual solving or third-party services
  • Rate limiting - Solving challenges too frequently may trigger additional protections
  • WAF rules - Some sites use custom WAF rules beyond Cloudflare’s standard challenges

Best Practices

  1. Use sessions - Reuse cookies across requests to avoid re-solving
  2. Set adequate timeout - Minimum 60 seconds, 90-120 seconds recommended
  3. Monitor logs - Check for challenge detection and solving status
  4. Combine with other features - Use with hide_canvas, block_webrtc, etc.
  5. Respect rate limits - Add delays between requests

Anti-Bot Bypass

General anti-bot bypass strategies

Handling Blocked Requests

Detect and retry blocked requests

Error Handling

Handle errors and timeouts

Performance Tips

Optimize scraping performance