Skip to main content

A Python package for managing and using rotating proxies

Project description

Rotating Proxy

GitHub Release PyPI Downloads

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:

pip install rotating-proxy

Usage

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rotating_proxy-0.3.2.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rotating_proxy-0.3.2-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file rotating_proxy-0.3.2.tar.gz.

File metadata

  • Download URL: rotating_proxy-0.3.2.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for rotating_proxy-0.3.2.tar.gz
Algorithm Hash digest
SHA256 b04e8cfe5db88e16d05623fb05b0828ad6fec495707cfbdc016c7d92ab775130
MD5 933af87b2c345fdb414e848e2c815c36
BLAKE2b-256 54c12578208dd085264226d742de4c3b001be10396ac05bd46564aa2abe7a734

See more details on using hashes here.

Provenance

The following attestation bundles were made for rotating_proxy-0.3.2.tar.gz:

Publisher: publish.yml on Will6855/Rotating-Proxy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rotating_proxy-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: rotating_proxy-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 9.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for rotating_proxy-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9fd38bdcb7bd02dea61a249624db406a49d2f6d239e32d0eedfad4218a17aa76
MD5 5c7f1b84b5ab460895dff3af8698ea4f
BLAKE2b-256 4a3385c901c978c7102357b503fcf0696a3a72ea210c9582d1fc8cd74b76e67b

See more details on using hashes here.

Provenance

The following attestation bundles were made for rotating_proxy-0.3.2-py3-none-any.whl:

Publisher: publish.yml on Will6855/Rotating-Proxy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page