The automatic proxy rotation module

rotator

class saferequests.proxyrotation.rotator.ProxyRotator(*, anonymity=None, cachedir=None, countryset=None, livecheck=False, maxshape=0, repository='asyncio', schedule=0.0, secure=True)

Bases: object

A class that automatically rotates proxy addresses for HTTP requests

It allows specifying various filters, such as anonymity level, connection security, ISO 3166-1 alpha-2 country code, and downloading from free public sources, while ensuring the sanity of any proxy address retrieved.

property crawledset: set[Proxy]

The set of crawled proxy addresses

rotate()

It rotates blocking the selected proxy address

Return type:

None

property selected: Proxy | None

The selected proxy address

saferequests.proxyrotation.rotator.is_ipv4_address(address)

If a proxy address conforms to a IPv4 address

Return type:

bool

asyncio repository

class saferequests.proxyrotation.repository.asyncio.Repository(batchsize=10)

Bases: abc_Repository

batch_download()

It downloads a batch of proxy addresses from free public sources

Return type:

set[Proxy]

reachability(available)

It separates available proxy addresses into reachable and unreachable

Return type:

tuple[set[Proxy], set[Proxy]]