Expand description
Proxy configuration and rotation for HTTP requests.
When scraping at scale, routing requests through proxy servers helps avoid IP-based rate limiting and bans. This module provides two mechanisms:
- Static proxy – A single
Proxyset onFetcherConfigthat is used for every request. - Proxy rotation – A
ProxyRotatorthat cycles through a pool of proxies, picking the next one for each request according to aRotationStrategy.
The is_proxy_error helper function inspects error messages to determine whether
a failure was proxy-related, which is useful for deciding whether to retry with a
different proxy.
Structs§
- Proxy
Rotator - Thread-safe proxy rotator that cycles through a list of proxies using a configurable strategy.
Enums§
- Proxy
- A proxy server specification, either as a URL string or a structured configuration.
Functions§
- cyclic_
rotation - The default rotation strategy that cycles through proxies sequentially (0, 1, 2, …,
then back to 0). The returned index is wrapped with modulo in
ProxyRotator::get_proxy, so this simply returnscurrent + 1. - is_
proxy_ error - Returns
trueif the error message indicates a proxy-related failure. This checks for common proxy error patterns like “connection refused”, “tunnel failed”, etc. Useful in retry logic to decide whether to switch to a different proxy.
Type Aliases§
- Rotation
Strategy - A function that determines the next proxy index given the proxy list and the current index. Implement your own to create custom rotation strategies (e.g., random, weighted, or geo-aware selection).