import requests

# List of proxies
proxy_list = [
    'proxy1.example.com:8000',
    'proxy2.example.com:8000',
    'proxy3.example.com:8000',
    # Add more proxies as needed
]

# Function to rotate proxies
def get_proxy():
    global proxy_list
    proxy = proxy_list.pop(0)
    proxy_list.append(proxy)
    return {'http': 'http://' + proxy, 'https': 'https://' + proxy}

# Function to make a request using rotated proxy
def make_request(url):
    try:
        proxy = get_proxy()
        response = requests.get(url, proxies=proxy)
        if response.status_code == 200:
            return response.text
        else:
            print(f"Request failed with status code: {response.status_code}")
            return None
    except Exception as e:
        print(f"An error occurred: {str(e)}")
        return None

# Example usage
if __name__ == "__main__":
    target_url = 'http://example.com'
    for _ in range(10):  # Make 10 requests
        response = make_request(target_url)
        if response:
            print(response)
        else:
            print("Request failed.")

This script defines a list of proxies and provides functions to rotate through them for each request. You can adjust the proxy list and target URL according to your requirements. Make sure to replace 'http://example.com' with the URL you want to send requests to.

Comments (0)

There are no comments here yet, you can be the first!

Leave a Reply

Your email address will not be published. Required fields are marked *


Choose and Buy Proxy

Datacenter Proxies

Rotating Proxies

UDP Proxies

Trusted By 10000+ Customers Worldwide

Proxy Customer
Proxy Customer
Proxy Customer flowch.ai
Proxy Customer
Proxy Customer
Proxy Customer