Proxy-aware drop-in wrapper around requests with rotation and session support.
Project description
requests-prox
requests-prox is a proxy-aware wrapper around requests designed to stay familiar while adding practical proxy rotation behavior.
It is intended as a drop-in style approach for users who want to write:
import requests_prox as requests
and keep using the common requests API (get, post, Session, etc.) with proxy helpers.
Features
- Requests-compatible API surface for common usage
- Flexible proxy configuration (list, file, env var, local fallback)
- Proxy normalization and rotation
- Session support with optional fixed proxy or per-request rotation
- Retry behavior for common transient proxy/network failures
- Automatic removal of repeatedly failing proxies from the in-memory/file pool
Installation
Install from PyPI:
pip install requests-prox
Install directly from GitHub:
pip install git+https://github.com/its-wajd/requests-prox.git
Quick Usage
import requests_prox as requests
response = requests.get("https://httpbin.org/get", timeout=15)
print(response.status_code)
requests-prox re-exports these public names:
Response,Request,PreparedRequest,exceptionsSessionrequest,get,post,put,delete,patch,head,optionsload_proxies,save_proxies,reload_proxies,get_random_proxy,build_proxy_dict
Proxy Setup (Priority Order)
requestspro resolves proxies in this order:
- Direct proxy list (
proxy_list=[...]) - Explicit proxy file path (
proxy_file="...") - Environment variable (
REQUESTSPRO_PROXY_FILE) - Local fallback (
./proxy.txt) - No proxies (direct requests behavior)
This design avoids modifying anything inside site-packages and keeps user proxy data outside the package source.
Supported Proxy Formats
One proxy per line (file mode), or one proxy per item (list mode).
host:porthost:port:username:passwordhttp://host:porthttps://host:porthttp://username:password@host:port
Example:
127.0.0.1:8080
10.0.0.1:3128:user:pass
http://user:pass@192.168.1.20:8000
Environment Variable Usage
Linux/macOS:
export REQUESTSPRO_PROXY_FILE=/path/to/proxy.txt
Windows (cmd):
set REQUESTSPRO_PROXY_FILE=C:\path\to\proxy.txt
After setting the variable, normal usage automatically loads proxies from that path:
import requests_prox as requests
r = requests.get("https://httpbin.org/ip", timeout=15)
print(r.status_code)
Session Usage
Use an explicit proxy file:
import requests_prox as requests
s = requests.Session(proxy_file="/path/to/proxy.txt")
r = s.get("https://httpbin.org/ip", timeout=15)
print(r.status_code)
Use a direct proxy list (highest priority):
import requests_prox as requests
s = requests.Session(
proxy_list=[
"http://1.2.3.4:8080",
"http://user:pass@1.2.3.4:8080",
]
)
r = s.get("https://httpbin.org/ip", timeout=15)
print(r.status_code)
Rotate on each request:
import requests_prox as requests
s = requests.Session(proxy_file="proxy.txt", rotate_on_each_request=True)
r = s.get("https://httpbin.org/ip", timeout=15)
print(r.status_code)
Notes and Limitations
- This package is synchronous and built on top of
requests. - If no proxies are available, requests fall back to direct requests behavior.
- Proxy health/removal logic is simple by design (failure-count based).
- Keep your real proxy credentials out of source control; do not commit local
proxy.txt.
Author
Wajd Dev (@its-wajd)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file requests_prox-0.1.0.tar.gz.
File metadata
- Download URL: requests_prox-0.1.0.tar.gz
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
873c10ac52379217bcc6137e1483b0fc19778990b7576e0e31aad0b46172c000
|
|
| MD5 |
f1b50a9ae02d9fa53476192c71abd876
|
|
| BLAKE2b-256 |
d5cb3cda05d1f09094a5657e55bfb09b727de749153e75618429ce7980ee3a0a
|
File details
Details for the file requests_prox-0.1.0-py3-none-any.whl.
File metadata
- Download URL: requests_prox-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c7670fd89c16a9788ed8f5feeb6dfc4b22e2ff53048dec398061b6371715f1df
|
|
| MD5 |
a3da1ecf36f16a875c2e101aebb7e125
|
|
| BLAKE2b-256 |
6741c223d9c8d5b217ed38b64e7ce08f1fe2d2b5b321d0ce1fda56c17dd4cf88
|