Skip to content

lr2bmail/proxy11-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

proxy11

PyPI Python License: MIT

Official Python client for the Proxy11 proxy API.

Use it to fetch fresh proxy lists, filter by country or anonymity type, rotate through proxies, and export simple ip:port files.

Install

pip install proxy11

Quick Start

from proxy11 import ProxyClient

client = ProxyClient(api_key="YOUR_API_KEY")

proxies = client.get(limit=50, country="us")
proxy = client.random(proxy_type="anonymous")
proxy_list = client.as_list(limit=100)

Examples

Get Proxies

proxies = client.get(limit=50, country="us", proxy_type="anonymous", speed=1.0)

Get ip:port List

proxies = client.as_list(limit=50)
# ["103.152.112.166:8080", "45.77.56.114:4145"]

Random Proxy

proxy = client.random(country="us")
proxy_details = client.random_proxy()

Save to File

count = client.save("proxies.txt", country="us")
print(f"saved {count} proxies")

Rotator

rotator = client.rotator(country="us", proxy_type="anonymous", auto_refresh=True, refresh_after=50)

for _ in range(100):
    proxy = rotator.next()
    print(proxy)
    # if proxy fails:
    # rotator.mark_dead(proxy)

Auto-Rotating Requests Session

session = client.session(country="us", proxy_type="anonymous")

resp = session.get("https://httpbin.org/ip", timeout=15)
print(resp.json())

Error Handling

from proxy11 import APIError, NoProxiesError, ProxyClient

client = ProxyClient("YOUR_API_KEY")

try:
    proxy = client.random(country="us")
except NoProxiesError:
    print("No proxies matched the filters")
except APIError as exc:
    print(f"Proxy11 API error: {exc}")

API

Method Description
get(**filters) Return proxy rows as dictionaries
as_list(**filters) Return proxies as ip:port strings
random(**filters) Return one random ip:port proxy
random_proxy(**filters) Return one random proxy dictionary
save(path, **filters) Save ip:port proxies to a file
rotator(**filters) Create a proxy rotator
session(**filters) Create a requests.Session with rotating proxies

Filters

Parameter Type Description
limit int Max proxies to return, capped by your plan
country string Country name or two-letter country code
port int Proxy port
speed float Max response time in seconds
proxy_type string anonymous or transparent

Links

License

MIT

About

Python client for the Proxy11 proxy API

Topics

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages