class proxyproviders.providers.proxy_list.ProxyList(proxies: Iterable[str | Proxy], config: ProxyConfig | None = None)[source]

Bases: ProxyProvider

A 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 Proxy or text in any form Proxy.from_string() accepts: a URL such as http://user:pass@host:port or socks5://host:port, or host:port:user:pass

  • config – 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