proxy-manager
This module loads and returns proxies for easy use with requests.
Installation
This module is available via pip:
$ pip install proxy-manager
Basic Usage
proxies.txt:
00.11.222.33:4444 55.66.777.88:9999:username:password
test.py:
from proxymanager import ProxyManager
proxy_manager = ProxyManager('proxies.txt')
random_proxy = proxy_manager.random_proxy()
print(random_proxy) # { 'http':'http://...', 'https':'https://...' }
first_proxy = proxy_manager.next_proxy()
print(first_proxy.get_dict()) # { 'http':'http://00.11.222.33:4444', 'https':'https://00.11.222.33:4444' }
second_proxy = proxy_manager.next_proxy()
print(second_proxy.get_dict()) # { 'http':'http://username:password@55.66.777.88:9999', 'https':'https://username:password@55.66.777.88:9999' }
third_proxy = proxy_manager.next_proxy()
print(third_proxy.get_dict()) # { 'http':'http://00.11.222.33:4444', 'https':'https://00.11.222.33:4444' }
Documentation
Proxy File Format
Proxies in proxy files must have one of the following formats:
ip:port
or
ip:port:username:password
These can be combined and alternated.
ProxyManager
ProxyManager(proxy_file_path)
Returns a new ProxyManager instance given the path to a proxy file.
Parameters
string - File path to the proxy
Returns
ProxyManager - ProxyManager with proxies loaded
Example
from proxymngr import ProxyManager
proxy_manager = ProxyManager('proxies.txt')
ProxyManager.random_proxy
ProxyManager.random_proxy()
Returns a random proxy of those loaded into the proxy manager
Parameters
none
Returns
Proxy - Random proxy as a Proxy object
Example
random_proxy = proxy_manager.random_proxy()
print(random_proxy.get_dict()) # { 'http':'http://...', 'https':'https://...' }
ProxyManager.next_proxy
ProxyManager.next_proxy()
Returns proxies consecutively. Thread-safe. Loops continuously through available proxies, with wrapping.
Parameters
none
Returns
Proxy - Next proxy as a Project object
Example
first_proxy = proxy_manager.next_proxy()
print(first_proxy.get_dict()) # { 'http':'http://00.11.222.33:4444', 'https':'https://00.11.222.33:4444' }
Documentation for the Proxy object
Fields
string - ip string - port bool - is_auth string - username string - password
Proxy.get_dict
Proxy.get_dict()
Parameters
none
Returns
dict - Proxy as a dict in the form { 'http':'http://...', 'https':'https://...' } for use with requests
Example
```py proxy = proxy_manager.next_proxy() proxy_dict = first_proxy.get_dict() print(proxy_dict.get_dict()) # { ‘http’:’http://00.11.222.33:4444’, ‘https’:’https://00.11.222.33:4444’ }
Metadata
Release files for proxy-manager 0.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| proxy-manager-0.0.6.tar.gz | 3.9 kB | Without provenance | Details |
Release files / proxy-manager-0.0.6.tar.gz
| Download URL | proxy-manager-0.0.6.tar.gz |
|---|---|
| Size | 3.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f02bb58d74da89d8aecb27742907dfb2dc18771c388364d2f490d3a1fb36be24
|
|
BLAKE2b-256 checksum How to use checksums |
e08939532288e7fa6f36e33ecc9f3a06678e706dc06c856b1c022034c3d1ba0f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for proxy-manager 0.0.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.