Anonymous HTTP requests via rotating proxies and Tor
Project description
Anon Requests
anonymous python requests
Install
pip install anon_requests
Usage
see examples folder for more use cases
Proxies
from anon_requests import RotatingProxySession
from anon_requests import ProxyType
# validate=True will check if all proxies are functioning (default False)
# validated proxies will be used first
# "bad" proxies will be tried once you run out of good proxies
# everytime it runs out of unused proxies, it will start reusing old ones
# pass ignore_bad=False to not try the "bad" proxies at all (default True)
with RotatingProxySession(proxy_type=ProxyType.SOCKS5, validate=True) \
as session:
for i in range(5):
# every request rotates proxy before being made
# keeps trying until we get 200 status code
# will only repeat a proxy once all have been tried
# this means it can hang for a while here until request succeeds
response = session.get('https://ipecho.net/plain', timeout=5)
print(response.text) # Not your ip address, different every time
Tor
from anon_requests import RotatingTorSession
# Choose a proxy port, a control port, and a password.
# Defaults are 9050, 9051, and None respectively.
# If there is already a Tor process listening the specified
# ports, TorSession will use that one.
# Otherwise, it will create a new Tor process,
# and terminate it at the end.
with RotatingTorSession(proxy_port=9050, ctrl_port=9051,
password="MYSUPERSAFEPSWD") as session:
for i in range(5):
response = session.get('https://ipecho.net/plain')
print(response.text) # not your IP address, different every time
Custom transport
Every session accepts a session_factory — any callable returning a
requests.Session (the default is requests.Session). Rotation and proxy/Tor
settings are applied to whatever session the factory returns, so you can layer
a custom transport (for example an anti-bot session that bypasses Cloudflare)
under the rotation.
from anon_requests import RotatingProxySession, ProxyType
# any requests.Session subclass works here
with RotatingProxySession(
proxy_type=ProxyType.SOCKS5,
session_factory=lambda: MyAntiBotSession()) as session:
response = session.get('https://ipecho.net/plain', timeout=5)
See examples/composable_transport.py.
Proxy Sources
Proxies are scrapped from the following websites
- http://free-proxy.cz
- https://free-proxy-list.net
- https://www.socks-proxy.net
- https://www.sslproxies.org
- https://www.us-proxy.org
- https://hidemy.name
- http://proxydb.net
- https://www.proxynova.com
- https://www.proxyscan.io
- http://pubproxy.com
- https://spys.me
- https://spys.one
TODO
- import/export proxy list
- suggest more in github issues!
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 anon_requests-1.0.0a1.tar.gz.
File metadata
- Download URL: anon_requests-1.0.0a1.tar.gz
- Upload date:
- Size: 25.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0dc4662ad90606d98f299895464dee37a5d22e1bfb1de045566cf3c45e8f27d0
|
|
| MD5 |
cacbbeb60c6684ce3955c71333cefd98
|
|
| BLAKE2b-256 |
24fecaa5906bde9b3b75dfa45774c5a8a88a54b49496a8f4d5b21385fff107d5
|
File details
Details for the file anon_requests-1.0.0a1-py3-none-any.whl.
File metadata
- Download URL: anon_requests-1.0.0a1-py3-none-any.whl
- Upload date:
- Size: 30.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cbb0643e6605808e5df96943c28cc0dd91001d22b9a2576ff02749b04995458a
|
|
| MD5 |
18ca24b8f8855359da572a7ec3d035cc
|
|
| BLAKE2b-256 |
bb2611cb3ebe9959dc159ddb4b6ccb5ef17832104e349789083a4a8a7f17a193
|