Proxylist Package

Test Status Code Quality Type Check Test Coverage Status Pypi Downloads Documentation Status

The proxylist package provides function and classes for:

  • loading list of proxy servers from different sources like local file or network location

  • rotating proxy servers or picking them randomly

Feel free to give feedback in Telegram groups: @grablab and @grablab_ru.

Usage Example

>>> from proxylist import ProxyList
>>> pl = ProxyList.from_local_file('var/proxy.txt')
>>> pl.get_random_server()
<proxylist.server.ProxyServer object at 0x7f1882d599e8>
>>> pl.get_random_server().address()
'1.1.1.1:8085'
>>> len(pl)
1000

Installation

Run: pip install -U proxylist

Documentation

Documentation is available at http://proxylist.readthedocs.org

API Reference

This page contains auto-generated API reference documentation 1.

proxylist

Submodules
proxylist.base
Module Contents
Classes

BaseProxySource

class proxylist.base.BaseProxySource[source]
abstract get_servers_list() list[proxylist.server.ProxyServer][source]
proxylist.errors
Module Contents
exception proxylist.errors.ProxyListError[source]

Bases: Exception

Common base class for all non-exit exceptions.

exception proxylist.errors.InvalidProxyLine[source]

Bases: ProxyListError

Common base class for all non-exit exceptions.

exception proxylist.errors.ProxySourceReadError[source]

Bases: ProxyListError

Common base class for all non-exit exceptions.

proxylist.parser
Module Contents
Functions

parse_proxy_line(→ tuple[str, int, None | str, None | str])

Parse proxy details from the text line.

parse_servers_from_text(...)

Iterate proxy servers found in the content of text file.

proxylist.parser.parse_proxy_line(line: str) tuple[str, int, None | str, None | str][source]

Parse proxy details from the text line.

The text line could be in one of the following formats: * host:port * host:port:username:password

proxylist.parser.parse_servers_from_text(data: str, proxy_type: None | str, proxy_auth: None | tuple[str, str] = None) collections.abc.Iterator[proxylist.server.ProxyServer][source]

Iterate proxy servers found in the content of text file.

proxylist.proxylist
Module Contents
Classes

ProxyList

Class to work with proxy list.

class proxylist.proxylist.ProxyList(source: proxylist.source.BaseProxySource)[source]

Class to work with proxy list.

classmethod from_local_file(path: str, **kwargs: Any) ProxyList[source]

Create proxy list from file.

classmethod from_network_file(url: str, **kwargs: Any) ProxyList[source]

Create proxy list from network document.

classmethod from_lines_list(items: collections.abc.Sequence[str], **kwargs: Any) ProxyList[source]

Create proxy list from list of strings.

load() None[source]

Load proxy list from configured proxy source.

get_random_server() proxylist.server.ProxyServer[source]

Return random server.

get_next_server() proxylist.server.ProxyServer[source]

Return next server.

size() int[source]

Return number of proxies in the list.

__iter__() collections.abc.Iterator[proxylist.server.ProxyServer][source]
__len__() int[source]
__getitem__(key: int) proxylist.server.ProxyServer[source]
proxylist.server
Module Contents
Classes

ProxyServer

class proxylist.server.ProxyServer[source]

Bases: NamedTuple

host :str
port :int
username :None | str
password :None | str
proxy_type :None | str
get_address() str[source]
get_userpwd() None | str[source]
proxylist.source
Module Contents
Classes

BaseProxySource

class proxylist.source.BaseProxySource[source]
abstract get_servers_list() list[proxylist.server.ProxyServer][source]
Package Contents
Classes

ProxyList

Class to work with proxy list.

ProxyServer

LinesListProxySource

Load list from python list of strings.

LocalFileProxySource

Load list from the file.

NetworkFileProxySource

Load list from web resource.

class proxylist.ProxyList(source: proxylist.source.BaseProxySource)[source]

Class to work with proxy list.

classmethod from_local_file(path: str, **kwargs: Any) ProxyList[source]

Create proxy list from file.

classmethod from_network_file(url: str, **kwargs: Any) ProxyList[source]

Create proxy list from network document.

classmethod from_lines_list(items: collections.abc.Sequence[str], **kwargs: Any) ProxyList[source]

Create proxy list from list of strings.

load() None[source]

Load proxy list from configured proxy source.

get_random_server() proxylist.server.ProxyServer[source]

Return random server.

get_next_server() proxylist.server.ProxyServer[source]

Return next server.

size() int[source]

Return number of proxies in the list.

__iter__() collections.abc.Iterator[proxylist.server.ProxyServer][source]
__len__() int[source]
__getitem__(key: int) proxylist.server.ProxyServer[source]
class proxylist.ProxyServer[source]

Bases: NamedTuple

host :str
port :int
username :None | str
password :None | str
proxy_type :None | str
get_address() str[source]
get_userpwd() None | str[source]
class proxylist.LinesListProxySource(lines: collections.abc.Sequence[str], **kwargs: Any)[source]

Bases: BaseFileProxySource

Load list from python list of strings.

load_content() str[source]
class proxylist.LocalFileProxySource(path: str, **kwargs: Any)[source]

Bases: BaseFileProxySource

Load list from the file.

load_content() str[source]
class proxylist.NetworkFileProxySource(url: str, **kwargs: Any)[source]

Bases: BaseFileProxySource

Load list from web resource.

load_content() str[source]
1

Created with sphinx-autoapi