Skip to main content
Scrapling provides built-in mechanisms to detect blocked requests and automatically retry them with different strategies.

Spider Blocked Request Detection

The Spider class has built-in support for detecting and handling blocked requests:

Default Blocked Status Codes

Scrapling automatically detects these HTTP status codes as blocked:
Source: scrapling/spiders/spider.py:16

Custom Block Detection

Override the is_blocked() method to implement custom detection logic:
Source: scrapling/spiders/spider.py:190-194

Retry Configuration

Max Blocked Retries

Control how many times a blocked request is retried:
Source: scrapling/spiders/spider.py:79

Retry with Modified Request

Customize the request before retrying:
Source: scrapling/spiders/spider.py:196-198

Proxy Error Detection

Scrapling automatically detects proxy-related errors:
Source: scrapling/engines/toolbelt/proxy_rotation.py:7-15

Automatic Proxy Rotation on Failure

When using ProxyRotator, Scrapling automatically rotates proxies on errors:
Implementation: scrapling/engines/_browsers/_stealth.py:269-283

Fetcher-Level Retry Logic

Automatic Retries

Fetchers automatically retry failed requests:
Configuration: scrapling/engines/_browsers/_validators.py:88-89

Retry Loop Implementation

Here’s how Scrapling retries internally:
Source: scrapling/engines/_browsers/_stealth.py:478-539

Error Handling Hooks

On Error Callback

Handle errors in spiders:
Source: scrapling/spiders/spider.py:178-184

Complete Example

Combining all features:

Session-Level Error Handling

For standalone fetchers:

Best Practices

Don’t rely only on status codes:
Start simple, escalate to advanced techniques:
Track and alert on high error rates:
Proxies help avoid IP-based blocking:

Anti-Bot Bypass

Bypass anti-bot systems

Cloudflare Turnstile

Solve Cloudflare challenges

Error Handling

Complete error handling guide

Performance

Optimize retry performance