A library to add the ability to swap(rotate) proxies easily
This library will provide a Proxy class to manage all of your porxies plus Rotator class to obtain a Proxy based on weights of proxies. An exelent fit for requests and selenium libraries
An example usage for "selenium" library
from proxy_rotator import Proxy, Rotator
proxies: list[Proxy] = []
# Load proxies from a file
proxies_json = load_proxies("proxies.json")
for proxy_item in proxies_json:
proxies.append(Proxy(
proxy_item['path'],
proxy_item['type'],
proxy_item['protocol'],
proxy_item['status'],
proxy_item['weight'])
)
# Make a rotation for a proxy
rotator = Rotator(proxies)
# Get the random proxy by weight
proxy = rotator.get()
# Create a webdriver and put new proxy in use
firefox_opt = Options()
firefox_opt.add_argument('--headless')
firefox_opt.add_argument("--no-sandbox")
firefox_opt.add_argument("--disable-dev-shm-usage")
firefox_opt.add_argument(f"--proxy-server={proxy}")
driver = webdriver.Firefox(options=firefox_opt)
An example usage for "requests" library
from simple_proxy_rotator import proxy_to_requests_proxy
from simple_proxy_rotator.proxy_rotator import Proxy, Rotator
proxies: list[Proxy] = []
# Load proxies from a file
proxies_json = load_proxies("proxies.json")
for proxy_item in proxies_json:
proxies.append(Proxy(
proxy_item['path'],
proxy_item['type'],
proxy_item['protocol'],
proxy_item['status'],
proxy_item['weight'])
)
# Make a rotation for a proxy
rotator = Rotator(proxies)
# Get the random proxy by weight
rotator_proxy = rotator_.get()
# The returned proxy must be convert into string
# to be passed to requests.get method
proxy = proxy_to_requests_proxy(rotator_proxy.ip, rotator_proxy.protocol)
board_page = requests.get(url=url_, headers=conf.headers, proxies=proxy)
An example of "proxies.json" file content
{
"path": "100.100.100.100:1080",
"protocol": "socks4",
"type": "mobile",
"weight": 1250.8024368286133,
"status": "alive"
},
{
"path": "100.100.100.100:1080",
"protocol": "http",
"type": "mobile",
"weight": 1258.7508733272552,
"status": "dead"
},
{
"path": "100.100.100.100:1080",
"protocol": "https",
"type": "datacenter",
"weight": 1350.0,
"status": "alive"
},
{
"path": "100.100.100.100:1080",
"protocol": "https",
"type": "datacenter",
"weight": 850.4147324562073,
"status": "dead"
},
{
"path": "100.100.100.100:1080",
"protocol": "socks4",
"type": "datacenter",
"weight": 1253.0103130340576,
"status": "alive"
},
{
"path": "100.100.100.100:1080",
"protocol": "socks5",
"type": "datacenter",
"weight": 1250.8180613517761,
"status": "alive"
}
]
Metadata
Release files for simple-proxy-rotator 0.0.1
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 | Actions |
|---|---|---|---|---|
| simple_proxy_rotator-0.0.1.tar.gz | 5.9 MB | Without provenance | Details for simple_proxy_rotator-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| simple_proxy_rotator-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for simple_proxy_rotator-0.0.1-py3-none-any.whl |
Total release size: 5.9 MB
Release files / simple_proxy_rotator-0.0.1.tar.gz
| Download URL | simple_proxy_rotator-0.0.1.tar.gz |
|---|---|
| Size | 5.9 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f34676e0fef511562de051a54c636bfaf8bd029bb922b8cb0630b00f6453e02d
|
|
BLAKE2b-256 checksum How to use checksums |
890f63120e8853a513059d939ee331f3d95ce78d143f49787448492733067c1b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.4
|
Release files / simple_proxy_rotator-0.0.1-py3-none-any.whl
| Download URL | simple_proxy_rotator-0.0.1-py3-none-any.whl |
|---|---|
| Size | 16.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
294be3dde3f0870e0641a5688811630112e19875d2536e0373000f8e511590f5
|
|
BLAKE2b-256 checksum How to use checksums |
db6071aa6b656780d3328a2a0cb5fa0799465a71beafecbb7c9a5d26c3905569
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.4
|
Security for simple-proxy-rotator 0.0.1
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.