Skip to main content
Scrapling’s ProxyRotator provides thread-safe proxy rotation with pluggable strategies. It works seamlessly with all fetchers and sessions (HTTP, Stealthy, and Dynamic).

Basic Usage

With HTTP Sessions

With Browser Sessions

Proxy Formats

String Format (HTTP Sessions)

For FetcherSession:

Dict Format (Browser Sessions)

For StealthySession and DynamicSession:

Mixed Format Support

Rotation Strategies

Cyclic Rotation (Default)

Rotates through proxies sequentially:

Custom Rotation Strategy

Implement your own rotation logic:

Weighted Rotation

Give higher probability to certain proxies:

Sticky Session Strategy

Stick to one proxy until it fails:

Automatic Retry on Proxy Failure

Scrapling automatically detects proxy errors and retries with the next proxy:
Proxy errors detected:
  • net::err_proxy
  • net::err_tunnel
  • connection refused
  • connection reset
  • connection timed out
  • failed to connect
  • could not resolve proxy

Per-Request Proxy Override

Override the rotator for specific requests:

ProxyRotator API

Constructor

Methods

Usage with Different Sessions

FetcherSession

StealthySession

AsyncStealthySession

DynamicSession

Advanced Example: Rate-Limited Scraping

Rotate proxies to bypass rate limits:

Best Practices

Have at least 3-5 proxies in your rotation pool. More proxies = better distribution and resilience.
Set appropriate retries and retry_delay when using proxy rotation. Failed proxies will be skipped automatically.
Use string format for FetcherSession and dict format for browser sessions (StealthySession, DynamicSession).
Validate that your proxies work before adding them to the rotator. Bad proxies will cause retry delays.
Log proxy usage and failures to identify problematic proxies and optimize your pool.
Implement custom rotation strategies for weighted selection, geo-targeting, or performance-based rotation.

Proxy Rotation vs Static Proxy

Thread Safety

ProxyRotator is thread-safe and can be shared across threads:

Next Steps

Sessions

Learn more about session management

Spiders

Use proxy rotation in spider crawls