Skip to main content

A Python library for making HTTP requests through a rotating set of proxies.

Project description

ReqProxy

A Python library for making HTTP requests through a rotating set of proxies.

Overview

ReqProxy is a lightweight Python library that provides a simple way to make HTTP requests through a rotating set of proxies. It automatically handles proxy selection and error management, attempting multiple proxies until a successful response is received or all proxies have been tried.

Features

  • Supports all common HTTP methods (GET, POST, PUT, PATCH, DELETE)
  • Automatically rotates through a list of proxies
  • Handles proxy failures gracefully
  • Similar interface to the popular requests library
  • Configurable timeout and proxy sample size

Installation

pip install reqproxy

Usage

Basic Usage

from reqproxy import ProxyRequests

# List of proxy URLs
proxies = [
    "http://user1:pass1@192.168.1.1:8080",
    "http://user2:pass2@192.168.1.2:8080"
]

# Create a ProxyRequests instance
proxy_req = ProxyRequests(proxy_list=proxies)

# Make a GET request
response = proxy_req.get('https://example.com')
print(response.status_code)  # 200
print(response.text)  # HTML content

Making POST Requests with JSON Data

from reqproxy import ProxyRequests

proxies = ["http://user:pass@proxy.example.com:8080"]
proxy_req = ProxyRequests(proxy_list=proxies, timeout=5.0)

# JSON data to send
data = {"username": "test_user", "password": "test_pass"}

# Make a POST request with JSON data
response = proxy_req.post('https://api.example.com/login', json=data)
result = response.json()

Using Custom Parameters and Headers

headers = {"User-Agent": "Custom User Agent"}
params = {"page": 1, "limit": 10}

response = proxy_req.get(
    'https://api.example.com/products',
    params=params,
    headers=headers
)

Configuration Options

When creating a ProxyRequests instance, you can configure the following options:

  • proxy_list (required): A list of proxy URLs with the format "http://user:pass@ip:port"
  • proxy_sample_size (optional): The number of proxies to sample for each request (default: 10)
  • timeout (optional): The timeout for requests in seconds (default: 10.0)

Error Handling

If all proxies fail, a ProxyRequestException is raised containing all the individual errors:

from reqproxy import ProxyRequests, ProxyRequestException

try:
    proxy_req = ProxyRequests(proxy_list=["http://invalid.proxy:8080"])
    response = proxy_req.get('https://example.com')
except ProxyRequestException as e:
    print(f"All proxies failed: {e}")
    # Access individual errors
    for error in e.errors:
        print(f"Error: {error}")

Requirements

  • Python 3.12+
  • requests library

License

This project is licensed under the terms of the MIT license.

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

reqproxy-0.1.0.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

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

reqproxy-0.1.0-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file reqproxy-0.1.0.tar.gz.

File metadata

  • Download URL: reqproxy-0.1.0.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.13

File hashes

Hashes for reqproxy-0.1.0.tar.gz
Algorithm Hash digest
SHA256 73aa96e130113d2486a587961941ff59cac6a698284b4d1a8c3119de4e6ad98a
MD5 f10020c444633814397a859fe84d4062
BLAKE2b-256 cde944f518e035b7969b32cf6a44289dfd3e4cc420c76e01c84342e62b997f28

See more details on using hashes here.

File details

Details for the file reqproxy-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: reqproxy-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.13

File hashes

Hashes for reqproxy-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b4a479a51ecb00d2eb0e644c2cbb875c429e329dc3be56e413550394e276fc5b
MD5 db929620f345ac40f9c827f2cb28e9b5
BLAKE2b-256 531392929bf8b3fd5e8d3dfc1936af072706287ba5ecb2007309be59d809b572

See more details on using hashes here.

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