- Project Overview
- Architecture
- Installation
- Project Structure
- Code Documentation
- Testing
- Usage Examples
- Configuration
- Flow Diagrams
- Troubleshooting
FastProxy is a Python package designed to fetch and validate working web proxies from multiple sources. It uses multithreading for efficient proxy validation and provides both CLI and Python API interfaces.
- Multi-source proxy fetching (free-proxy-list.net and geonode.com)
- Concurrent proxy validation
- CSV export functionality
- Comprehensive logging system
- Both CLI and Python API interfaces
- Configurable timeout and thread settings
The project follows a modular architecture with the following key components:
fastProxy/
├── fastProxy/ # Main package directory
│ ├── __init__.py # Package initialization and version
│ ├── fastProxy.py # Core proxy validation logic
│ ├── logger.py # Logging configuration
│ └── proxy_sources/ # Proxy source implementations
│ ├── __init__.py # Source interface definitions
│ ├── manager.py # Proxy source management
│ ├── free_proxy_list.py# Free-proxy-list.net implementation
│ └── geonode.py # Geonode.com API implementation
├── tests/ # Test directory
│ └── unit/ # Unit tests
├── cli.py # CLI interface
└── getProxyNow.py # Python API example script
- Proxy Sources: Each source (free-proxy-list.net, geonode.com) implements a common interface for fetching proxies
- Source Manager: Coordinates proxy fetching from multiple sources
- Validator: Validates proxies using multithreading
- Logger: Provides detailed logging for debugging and monitoring
- Output Manager: Handles CSV generation and console output
pip install fastProxy==1.0.0
git clone https://github.com/1UC1F3R616/fastProxy.git
cd fastProxy
pip install -r requirements.txt
- Python 3.8+
- requests
- beautifulsoup4
- fire
- pytest (for testing)
- pytest-cov (for coverage)
- requests-mock (for testing)
-
manager.py: Manages multiple proxy sources
ProxySourceManager
: Coordinates proxy fetchingfetch_all()
: Fetches proxies from all sources
-
free_proxy_list.py: Free-proxy-list.net implementation
FreeProxyListSource
: Scrapes and parses proxy datafetch()
: Retrieves proxies using BeautifulSoup
-
geonode.py: Geonode.com API implementation
GeoNodeSource
: Fetches proxies from APIfetch()
: Retrieves and formats proxy data
alive_ip
: Thread class for proxy validationcheck_proxy()
: Validates individual proxiesfetch_proxies()
: Main entry point for proxy fetchinggenerate_csv()
: Exports results to CSV
- Configurable logging levels
- File and console output
- Rotation handling
- Detailed error tracking
- test_fastproxy.py: Core functionality tests
- test_logger.py: Logging system tests
- proxy_sources/: Source-specific tests
test_manager.py
: Source manager teststest_free_proxy_list.py
: Free-proxy-list source teststest_geonode.py
: Geonode API source tests
class ProxySourceManager:
"""Manages multiple proxy sources and aggregates results"""
def fetch_all(self, max_proxies=None):
"""
Fetches proxies from all registered sources
Args:
max_proxies (int, optional): Maximum proxies to fetch
Returns:
list: Combined proxy list from all sources
"""
class alive_ip(Thread):
"""
Thread class for proxy validation
Attributes:
proxy_data (dict): Proxy information
timeout (int): Request timeout
"""
def fetch_proxies(c=None, t=None, g=None, a=None):
"""
Main function to fetch and validate proxies
Args:
c (int): Thread count
t (int): Timeout in seconds
g (bool): Generate CSV
a (bool): Include all proxies
Returns:
list: Valid proxies
"""
Current test coverage: 86%
- fastProxy/fastProxy.py: 88%
- fastProxy/logger.py: 97%
- fastProxy/proxy_sources/init.py: 95%
- fastProxy/proxy_sources/free_proxy_list.py: 86%
- fastProxy/proxy_sources/geonode.py: 71%
- fastProxy/proxy_sources/manager.py: 100%
# Run all tests
python -m pytest tests/unit/ -v
# Run with coverage
python -m pytest tests/unit/ -v --cov=fastProxy --cov-report=term-missing
-
Core Functionality Tests
- Proxy validation
- Thread management
- CSV generation
-
Source Tests
- API responses
- Error handling
- Data parsing
-
Integration Tests
- Multi-source fetching
- End-to-end validation
# Basic usage
python cli.py
# With options
python cli.py --c=10 --t=5 --g --a
from fastProxy import fetch_proxies
# Basic usage
proxies = fetch_proxies()
# With options
proxies = fetch_proxies(c=10, t=5, g=True, a=True)
c
: Thread count (default: 256)t
: Request timeout in seconds (default: 2)g
: Generate CSV output (default: False)a
: Include all proxies (default: False)
[Start] -> [Initialize Sources]
-> [Fetch from Sources (Parallel)]
-> [Free-proxy-list.net] -> [Parse HTML] -> [Extract Proxies]
-> [Geonode API] -> [Parse JSON] -> [Extract Proxies]
-> [Combine Results]
-> [Initialize Thread Pool]
-> [Validate Proxies (Parallel)]
-> [HTTP Check] -> [HTTPS Check]
-> [Collect Results]
-> [Generate CSV (if enabled)]
[End]
[Log Event] -> [Format Message]
-> [Check Log Level]
-> [Console Output]
-> [File Output]
-> [Rotation Check]
-
Timeout Errors
- Increase timeout value with
--t
option - Reduce thread count with
--c
option
- Increase timeout value with
-
No Proxies Found
- Check internet connection
- Verify source websites are accessible
- Review logs in
logs/fastproxy.log
-
CSV Generation Issues
- Ensure write permissions in
proxy_list
directory - Check disk space
- Ensure write permissions in
-
High Memory Usage
- Reduce thread count
- Set maximum proxy limit
Enable detailed logging:
import logging
logging.getLogger('fastProxy').setLevel(logging.DEBUG)
Log files location: logs/fastproxy.log
Format: [TIMESTAMP] [LEVEL] [MODULE] Message
Example:
[2024-11-17 11:04:10] [INFO] [manager] Found 300 proxies from free-proxy-list.net
[2024-11-17 11:04:10] [INFO] [manager] Found 74 proxies from geonode.com