A simple Python package to fetch working proxies with filtering capabilities
Project description
ProxyFetcher
A simple Python package to fetch working proxies with filtering capabilities. Get proxies by speed, protocol (HTTP/HTTPS), and country.
Installation
pip install proxyfetcher
Quick Start
from proxy_fetcher import ProxyFetcher
# Create fetcher instance
fetcher = ProxyFetcher()
# Get 5 fastest proxies
fast_proxies = fetcher.get_fast_proxies()
print(fast_proxies)
# ['ip1:port1', 'ip2:port2', ...]
# Get HTTP/HTTPS proxies
http_proxies = fetcher.get_http_proxies()
https_proxies = fetcher.get_https_proxies()
# Get proxies by country
us_proxies = fetcher.get_country_proxies('US') # United States
uk_proxies = fetcher.get_country_proxies('UK') # United Kingdom (both 'UK' and 'GB' work)
# Get fast HTTPS proxies from specific country
fast_us_https = fetcher.get_country_proxies(
country_code='US',
max_speed_ms=1000, # Speed < 1000ms
protocol='https'
)
Features
- Get proxies in simple ip:port format
- Filter by protocol (HTTP/HTTPS)
- Filter by country (using country codes)
- Filter by speed (in milliseconds)
- Get fastest working proxies
- Combine multiple filters
API Reference
ProxyFetcher()
Create a new ProxyFetcher instance.
get_proxies(max_speed_ms: Optional[int] = None, country: Optional[str] = None, protocol: Optional[str] = None) -> List[str]
Get list of proxies with optional filters.
max_speed_ms: Maximum allowed speed in millisecondscountry: Country code (e.g., 'US', 'UK')protocol: Protocol filter ('http' or 'https')- Returns: List of proxy strings in ip:port format
get_fast_proxies(limit: int = 5, protocol: Optional[str] = None) -> List[str]
Get fastest working proxies.
limit: Number of proxies to return (default: 5)protocol: Optional protocol filter- Returns: List of fastest proxy strings
get_http_proxies(max_speed_ms: Optional[int] = None) -> List[str]
Get HTTP proxies.
max_speed_ms: Optional speed filter- Returns: List of HTTP proxy strings
get_https_proxies(max_speed_ms: Optional[int] = None) -> List[str]
Get HTTPS proxies.
max_speed_ms: Optional speed filter- Returns: List of HTTPS proxy strings
get_country_proxies(country_code: str, max_speed_ms: Optional[int] = None, protocol: Optional[str] = None) -> List[str]
Get proxies from specific country.
country_code: Country code (e.g., 'US', 'UK')max_speed_ms: Optional speed filterprotocol: Optional protocol filter- Returns: List of proxy strings from specified country
Example Usage in Projects
With Requests
import requests
from proxy_fetcher import ProxyFetcher
fetcher = ProxyFetcher()
proxies = fetcher.get_fast_proxies()
for proxy in proxies:
proxy_dict = {
'http': f'http://{proxy}',
'https': f'http://{proxy}'
}
try:
response = requests.get('http://example.com', proxies=proxy_dict)
print(f'Success with proxy: {proxy}')
break
except:
continue
With Selenium
from selenium import webdriver
from proxy_fetcher import ProxyFetcher
fetcher = ProxyFetcher()
proxy = fetcher.get_https_proxies(max_speed_ms=1000)[0]
options = webdriver.ChromeOptions()
options.add_argument(f'--proxy-server={proxy}')
driver = webdriver.Chrome(options=options)
With aiohttp
import aiohttp
from proxy_fetcher import ProxyFetcher
async def main():
fetcher = ProxyFetcher()
proxy = fetcher.get_fast_proxies(limit=1)[0]
async with aiohttp.ClientSession() as session:
async with session.get('http://example.com', proxy=f'http://{proxy}') as response:
html = await response.text()
Development
Setting up development environment
# Clone the repository
git clone https://github.com/proxyfetcher/proxyfetcher.git
cd proxyfetcher
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
Running tests
python test.py
Building and publishing to PyPI
# Build the package
python setup.py sdist bdist_wheel
# Upload to PyPI
twine upload dist/*
License
This project is licensed under the MIT License - see the LICENSE file for details.
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 proxyfox-0.1.1.tar.gz.
File metadata
- Download URL: proxyfox-0.1.1.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5e6d95b680921ae8687b3c10bc254b6792ea42fa2a446f407e847298d3d7f06e
|
|
| MD5 |
0d652ded0b20f9f80872f4e578738bbf
|
|
| BLAKE2b-256 |
8d1eb5cccce422477533f8f7e0140b08d161bc5c77e82c792c53647ac3157f97
|
File details
Details for the file proxyfox-0.1.1-py3-none-any.whl.
File metadata
- Download URL: proxyfox-0.1.1-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0204172d2b7b1ba4b47e1adebe97cd5e3522e1c9cb01f1e4070696234a5c5a68
|
|
| MD5 |
72a8dfe02458a745b0d2647d8e23d6cc
|
|
| BLAKE2b-256 |
b175de4d9d2b450387b7b742e8369a91da6aeac49a28fc5b7da779706d2c7941
|