ProxyProvider Shared Interface

class proxyproviders.proxy_provider.ProxyConfig(refresh_interval: float = 600)[source]

Bases: object

Provides standard shared configuration options for all proxy providers.

Example:

from proxyproviders import Webshare, ProxyConfig

config = ProxyConfig(refresh_interval=5)
proxy_provider = Webshare(api_key="your-api-key", config=config)
refresh_interval: float = 600

Duration in seconds after which the proxy list is refreshed to fetch new proxies. Set to 0 to disable automatic refreshing after the initial fetch.

class proxyproviders.proxy_provider.ProxyProvider(config: ProxyConfig | None = None)[source]

Bases: ABC

Base class for all proxy providers that provides shared functionality across all providers.

You’ll need to use a specific provider to fetch proxies and this shouldn’t directly be initialized. However, this class is useful for type hinting and for creating custom providers that are not included in the library, although consider contributing them to the library if you are making them.

Parameters:

config – Configuration for the proxy provider. View the ProxyConfig class docs for more information.

list_proxies(force_refresh: bool = False) List[Proxy][source]

Returns the stored proxies. If a format function is provided, it applies that function to each proxy.

Parameters:

force_refresh – If True, fetches new proxies even if the list is not considered stale.

should_refresh() bool[source]

Returns True if the proxy list should be refreshed based on the refresh_interval.