# Rotating Proxy


A Python package for managing and utilizing rotating proxies effectively. This module provides a simple and efficient way to handle multiple proxies, automatically switching between them to enhance web scraping or any HTTP requests that require anonymity.
## Features
- Proxy Pool Management: Easily add, remove, and manage a list of proxies.
- Automatic Proxy Rotation: Automatically rotates through working proxies to ensure seamless web requests.
- Proxy Testing: Verifies the functionality of each proxy before use, maintaining a blacklist of failed proxies.
- Support for HTTP and SOCKS proxies: Works with different types of proxies to meet your needs.
- Advanced Proxy Metrics: Track proxy performance with detailed success and failure metrics.
- Proxy Authentication: Support for authenticated proxies
- Background Health Checks: Periodic validation of proxy health
- Exponential Backoff: Intelligent retry mechanism for network requests
- Dynamic Test URL: Ability to change proxy validation URL
## Requirements
- Python 3.9+
- Dependencies:
- requests
- typing
- python-dateutil
- urllib3
- dataclasses (for Python < 3.7)
## Installation
You can install the package using pip:
```bash
pip install rotating-proxy
```
## Usage
```python
from rotating_proxy import ProxyPool, ProxySession
class Project:
def __init__(self):
# Initialize the proxy pool with proxies, including authentication support
self.proxy_pool = ProxyPool([
"http://username:password@proxy1:port",
"http://proxy2:port"
])
# Optional: Change test URL for proxy validation
self.proxy_pool.change_test_url('https://api.ipify.org')
# Filter and validate working proxies
self.proxy_pool.filter_working_proxies()
# Create proxy session with custom configuration
self.proxy_session = ProxySession(
self.proxy_pool,
timeout=15,
max_retries=3,
default_headers={'User-Agent': 'MyCustomUserAgent'}
)
def request_function(self, **kwargs):
try:
response = self.proxy_session.request(**kwargs)
print(f"IP Address: {response.json()['origin']}")
# Get proxy performance metrics
metrics = self.proxy_session.get_proxy_performance()
print(f"Proxy Performance: {metrics}")
except Exception as e:
print(f"Request failed: {e}")
if __name__ == "__main__":
project = Project()
project.request_function(url="https://httpbin.org/ip", method="GET")
```
## Advanced Features
### Proxy Metrics
The `ProxyMetrics` class tracks detailed information about each proxy:
- Success and failure counts
- Last used and last successful timestamps
- Proxy score
- Consecutive failures
### Customization
- Configurable timeout and retry settings
- SSL verification options
- Logging for tracking proxy performance
## Contributing
Contributions are welcome! If you have suggestions for improvements or additional features, feel free to open an issue or submit a pull request.
## License
This project is licensed under the MIT License. See the LICENSE file for details.
## Recent Updates
- Added support for advanced proxy metrics
- Improved dependency management
- Enhanced error handling and logging
- Expanded Python version compatibility
Raw data
{
"_id": null,
"home_page": "https://github.com/Will6855/rotating-proxy",
"name": "rotating-proxy",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": null,
"author": "Will",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/75/12/906a83046a378cfd0709ce5aa053d9ef20d8be69db278d146ffc9c96a3c4/rotating_proxy-0.3.1.tar.gz",
"platform": null,
"description": "# Rotating Proxy\n\n\n\nA Python package for managing and utilizing rotating proxies effectively. This module provides a simple and efficient way to handle multiple proxies, automatically switching between them to enhance web scraping or any HTTP requests that require anonymity.\n\n## Features\n\n- Proxy Pool Management: Easily add, remove, and manage a list of proxies.\n- Automatic Proxy Rotation: Automatically rotates through working proxies to ensure seamless web requests.\n- Proxy Testing: Verifies the functionality of each proxy before use, maintaining a blacklist of failed proxies.\n- Support for HTTP and SOCKS proxies: Works with different types of proxies to meet your needs.\n- Advanced Proxy Metrics: Track proxy performance with detailed success and failure metrics.\n- Proxy Authentication: Support for authenticated proxies\n- Background Health Checks: Periodic validation of proxy health\n- Exponential Backoff: Intelligent retry mechanism for network requests\n- Dynamic Test URL: Ability to change proxy validation URL\n\n## Requirements\n\n- Python 3.9+\n- Dependencies:\n - requests\n - typing\n - python-dateutil\n - urllib3\n - dataclasses (for Python < 3.7)\n\n## Installation\n\nYou can install the package using pip:\n\n```bash\npip install rotating-proxy\n```\n\n## Usage\n\n```python\nfrom rotating_proxy import ProxyPool, ProxySession\n\nclass Project:\n def __init__(self):\n # Initialize the proxy pool with proxies, including authentication support\n self.proxy_pool = ProxyPool([\n \"http://username:password@proxy1:port\",\n \"http://proxy2:port\"\n ])\n \n # Optional: Change test URL for proxy validation\n self.proxy_pool.change_test_url('https://api.ipify.org')\n \n # Filter and validate working proxies\n self.proxy_pool.filter_working_proxies()\n\n # Create proxy session with custom configuration\n self.proxy_session = ProxySession(\n self.proxy_pool, \n timeout=15, \n max_retries=3,\n default_headers={'User-Agent': 'MyCustomUserAgent'}\n )\n\n def request_function(self, **kwargs):\n try:\n response = self.proxy_session.request(**kwargs) \n print(f\"IP Address: {response.json()['origin']}\")\n \n # Get proxy performance metrics\n metrics = self.proxy_session.get_proxy_performance()\n print(f\"Proxy Performance: {metrics}\")\n except Exception as e:\n print(f\"Request failed: {e}\")\n\nif __name__ == \"__main__\":\n project = Project()\n project.request_function(url=\"https://httpbin.org/ip\", method=\"GET\")\n```\n\n## Advanced Features\n\n### Proxy Metrics\nThe `ProxyMetrics` class tracks detailed information about each proxy:\n- Success and failure counts\n- Last used and last successful timestamps\n- Proxy score\n- Consecutive failures\n\n### Customization\n- Configurable timeout and retry settings\n- SSL verification options\n- Logging for tracking proxy performance\n\n## Contributing\n\nContributions are welcome! If you have suggestions for improvements or additional features, feel free to open an issue or submit a pull request.\n\n## License\n\nThis project is licensed under the MIT License. See the LICENSE file for details.\n\n## Recent Updates\n\n- Added support for advanced proxy metrics\n- Improved dependency management\n- Enhanced error handling and logging\n- Expanded Python version compatibility\n",
"bugtrack_url": null,
"license": null,
"summary": "A Python package for managing and using rotating proxies",
"version": "0.3.1",
"project_urls": {
"Homepage": "https://github.com/Will6855/rotating-proxy"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "bcaad09b25ccf1719b53e571af304d2c9ca9da89243bc3ccc5c426bc77dd040c",
"md5": "4f304a39c1fd70db2c56e6246f562a8d",
"sha256": "5b68c47d2417553664becce50a8fa9f99bcfec834b5142c437692b794a0fdf53"
},
"downloads": -1,
"filename": "rotating_proxy-0.3.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "4f304a39c1fd70db2c56e6246f562a8d",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 9059,
"upload_time": "2025-01-19T20:03:17",
"upload_time_iso_8601": "2025-01-19T20:03:17.760345Z",
"url": "https://files.pythonhosted.org/packages/bc/aa/d09b25ccf1719b53e571af304d2c9ca9da89243bc3ccc5c426bc77dd040c/rotating_proxy-0.3.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "7512906a83046a378cfd0709ce5aa053d9ef20d8be69db278d146ffc9c96a3c4",
"md5": "ae7393263a87e3288822c398d941eaeb",
"sha256": "93f3b2218bab19ecb9a2836e13b42176329f11393a92c8b65ea000563c5066c9"
},
"downloads": -1,
"filename": "rotating_proxy-0.3.1.tar.gz",
"has_sig": false,
"md5_digest": "ae7393263a87e3288822c398d941eaeb",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 9247,
"upload_time": "2025-01-19T20:03:18",
"upload_time_iso_8601": "2025-01-19T20:03:18.903336Z",
"url": "https://files.pythonhosted.org/packages/75/12/906a83046a378cfd0709ce5aa053d9ef20d8be69db278d146ffc9c96a3c4/rotating_proxy-0.3.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-19 20:03:18",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Will6855",
"github_project": "rotating-proxy",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "requests",
"specs": [
[
"==",
"2.32.3"
]
]
},
{
"name": "typing",
"specs": [
[
"==",
"3.7.4.3"
]
]
},
{
"name": "dataclasses",
"specs": [
[
"==",
"0.8"
]
]
},
{
"name": "python-dateutil",
"specs": [
[
"==",
"2.9.0.post0"
]
]
},
{
"name": "urllib3",
"specs": [
[
"==",
"2.2.2"
]
]
}
],
"lcname": "rotating-proxy"
}