Skip to main content

This module loads and uses a proxy for the convenience of using requests, aiohttp, etc.
Fork https://pypi.org/project/proxy-manager/

Installation

This module is available via pip:

$ pip install proxy-MGR

Basic Usage

proxies.txt:

https://00.11.222.33:4444
https://55.66.77.88:9999@username:password
socks5://10.11.121.13:1414@username:password
15.16.171.18:1919
20.21.222.23:2424@username:password
25.26.272.28:2929:username:password

test.py:

from ProxyMGR import ProxyMGR

MGR = ProxyMGR("proxies.txt")
# MGR = ProxyMGR(proxy_list=["00.11.222.33:4444@username:password"])

# Random proxy
random_proxy = MGR.random_proxy()
print(random_proxy) # https://00.11.222.33:4444

# Next proxy
proxy = MGR.next_proxy()
print(proxy) # https://00.11.222.33:4444
proxy = MGR.next_proxy()
print(proxy) # https://55.66.77.88:9999@username:password
proxy = MGR.next_proxy()
print(proxy) # socks5://10.11.121.13:1414@username:password

# Proxy dict
print(random_proxy.get_dict()) # {'http': 'https://00.11.222.33:4444', 'https': 'https://00.11.222.33:4444'}

# Proxy info
print(random_proxy.get_info()) # {"ip":"81.222.188.37","success":true,"type":"IPv4","continent":"Europe" ...

Documentation

Proxy File Format

Proxies in proxy files must have one of the following formats:

ip:port
ip:port:username:password
ip:port@username:password
http://ip:port
...

These can be combined and alternated.

ProxyMGR

ProxyMGR(proxy_file_path)
ProxyMGR(proxy_list)

Parameters

  1. proxy_file_path (string) — File path to the proxy (Required, if proxy_list is not specified)
  2. proxy_list (list) — List proxy (Required, if proxy_file_path is not specified)
  3. default_type (string) — Default proxy type (example ip:port -> https://ip:port) (optional)

ProxyMGR.random_proxy()

Returns a random proxy of those loaded into the proxy manager

ProxyMGR.next_proxy()

Parameters

  1. loop (bool) — Repeat proxies if they run out

ProxyMGR.get_dict()

dict - Proxy as a dict in the form {'http':'http://...', 'https':'https://...'} for use with requests

ProxyMGR.get_info()

Website Request https://ipwho.is with proxy and return json

Release files for proxy-mgr 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for proxy-mgr 0.1.0
File Size Uploaded
proxy_mgr-0.1.0.tar.gz 2.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for proxy-mgr 0.1.0
File Interpreter ABI Platform
proxy_mgr-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 6.2 kB

Release files / proxy_mgr-0.1.0.tar.gz

Download URL proxy_mgr-0.1.0.tar.gz
Size 2.9 kB
Tags Source
SHA-256 checksum
How to use checksums
2fddb1bf986e9f1d6a4133ca803961cd7af234dd444bd8b975b38bd5121d4748
BLAKE2b-256 checksum
How to use checksums
d1846c0fa04909781da7d5907bc7873002332ad6c0f71f585366244ee090b5cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.5.1 CPython/3.10.0 Windows/10

Release files / proxy_mgr-0.1.0-py3-none-any.whl

Download URL proxy_mgr-0.1.0-py3-none-any.whl
Size 3.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1efc9867dbf2034a9e6a4c505e1c61db68a5679732e9eae395c4e7436c3f036d
BLAKE2b-256 checksum
How to use checksums
a9e59f33b633dc3d180be355687c94aebd41f0480209af32193580554f16e1dc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.5.1 CPython/3.10.0 Windows/10

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page