- class proxyproviders.providers.proxy_list.ProxyList(proxies: Iterable[str | Proxy], config: ProxyConfig | None = None)[source]
Bases:
ProxyProviderA provider for proxies you already have, from any vendor.
Use it when your vendor has no provider here yet, or when you manage the list yourself. You get the same interface as every other provider: selection algorithms, output formats, failure reporting and
RotatingSession.- Parameters:
proxies – The proxies, each either a
Proxyor text in any formProxy.from_string()accepts: a URL such ashttp://user:pass@host:portorsocks5://host:port, orhost:port:user:passconfig – Configuration for the proxy provider. View the ProxyConfig class docs for more information.
- Raises:
ValueError – If an entry cannot be parsed, or the list is empty
Example:
from proxyproviders import ProxyList provider = ProxyList( [ "http://user:pass@203.0.113.7:8080", "203.0.113.8:8080:user:pass", "socks5://user:pass@203.0.113.9:1080", ] ) proxy = provider.get_proxy() # Or one proxy per line from a file, ignoring blank lines and # comments provider = ProxyList.from_file("proxies.txt")
- classmethod from_file(path: str | Path, config: ProxyConfig | None = None) ProxyList[source]
Load proxies from a text file with one proxy per line.
Blank lines and lines starting with
#are skipped.- Parameters:
path – Path to the file
config – Configuration for the proxy provider