How to Integrate Evomi Proxies into Python Requests

Michael Chen

Last edited on May 15, 2025
Last edited on May 15, 2025

Setup Guides

Diving into Python Requests with Evomi Proxies

Integrating proxies using Python's Requests library is a pretty smooth process, thankfully, as the library has built-in support for it. Since Requests is a popular choice for tasks like web scraping, knowing how to plug in proxies is a fundamental skill.

This guide will walk you through using Evomi residential proxies with the Requests library. Keep in mind that the core concepts apply similarly to other proxy types, like datacenter or mobile proxies.

So, What's the Deal with Python Requests?

Python Requests is an HTTP library designed with simplicity and human-friendliness at its core. While Python has some built-in ways to handle HTTP, Requests offers a much more intuitive and streamlined experience. You can find more details in our overview of Python Requests.

Crucially for us, Requests directly supports basic proxy usage, making it a solid foundation for projects needing IP anonymity or rotation, such as web scraping. While some complex proxy authentication setups might require a little extra work, the basics are straightforward.

Its lightweight nature and efficiency also contribute to its popularity among developers. For many straightforward HTTP tasks, Requests is often the first tool reached for.

However, it does have a limitation: Requests doesn't natively handle asynchronous operations. For applications needing high concurrency (sending many requests simultaneously instead of one after another), this can be a drawback. While extensions exist, the lack of built-in async support might lead developers working on larger-scale projects to explore other libraries.

Getting Your Evomi Proxies Ready

First things first, you need the proxies themselves. While free proxies might seem tempting, they often come with significant downsides like poor performance, unreliability, or even security risks. We strongly advise using reputable providers.

At Evomi, we offer various proxy types to suit different needs, including:

  • Residential Proxies: Starting at $0.49/GB, ideal for mimicking real user behavior.

  • Mobile Proxies: From $2.2/GB, using mobile carrier IPs.

  • Datacenter Proxies: Highly affordable at $0.30/GB for speed.

  • Static ISP Proxies: Starting from $1/IP for stable, residential-like IPs.

To get started:

  1. Sign up for an account on the Evomi platform.

  2. Navigate to the product section (e.g., Residential Proxies) and choose a plan that suits your data needs. We even offer a completely free trial for Residential, Mobile, and Datacenter proxies so you can test them out!

  3. Once your plan is active, head to your Evomi dashboard. You'll find your proxy credentials and connection details there.

For integrating with Python Requests, you'll typically need the proxy details in the `user:pass@host:port` format. Your Evomi dashboard will provide the necessary components: your username, password, the proxy endpoint (like `rp.evomi.com` for residential), and the corresponding port (e.g., `1000` for HTTP on residential).

Alternative: IP Whitelisting

Evomi also supports IP whitelisting. Instead of using a username and password, you can authorize your own machine's IP address to use the proxies. You can find your current IP using a tool like our IP Geolocation Checker. Then, add this IP to the whitelist section in your Evomi dashboard.

This simplifies the connection string (just `host:port`) and prevents accidental credential leaks, especially if you share code publicly. However, you'll need to whitelist the IP of every machine you intend to use the proxies from.

Configuring Python Requests to Use Evomi Proxies

When you check your Evomi dashboard, you'll see our proxy endpoints (e.g., `rp.evomi.com`, `dc.evomi.com`, `mp.evomi.com`). You generally don't need a long list of individual proxy IPs because Evomi handles the IP rotation automatically on our end through these central endpoints. Just use the main endpoint provided for your chosen proxy type.

If you need an IP address to remain the same for a specific duration (a "sticky session"), you can usually configure this session length directly in your Evomi dashboard settings, rather than needing to manage it in your code.

Now, let's get coding. Open your preferred Python IDE (like PyCharm) and create a new project or file. First, ensure you have the Requests library installed. Open your terminal or command prompt and run:

With Requests installed, you can write a simple script to test the proxy integration. We'll send a request to a site that shows our IP address to confirm the proxy is working.

import requests

# Replace with your actual Evomi credentials and endpoint/port
# Example for HTTP Residential Proxy:
evomi_proxy_url = "http://YOUR_USERNAME:YOUR_PASSWORD@rp.evomi.com:1000"

# Define the proxies dictionary for Requests
proxy_config = {
    "http": evomi_proxy_url,
    "https": evomi_proxy_url, # Use the same proxy for HTTPS traffic
}

# A test URL that returns the request's IP address
target_url = "https://httpbin.org/ip"

try:
    # Make the GET request using the configured proxies
    response = requests.get(target_url, proxies=proxy_config, timeout=10)
    response.raise_for_status() # Raise an exception for bad status codes (4xx or 5xx)

    # Print the response content (which should show the proxy's IP)
    print("Request successful! Response:")
    print(response.json())

except requests.exceptions.RequestException as e:
    print(f"An error occurred: {e}")

This script defines the proxy connection string (make sure to replace the placeholders!), sets up the dictionary that Requests expects, and then makes a simple GET request through the proxy. Using an IP checker like `httpbin.org/ip` is handy because the response directly shows you the IP address seen by the target server, confirming your traffic is routed through the proxy.

Note that the proxy URL itself starts with `http://` (or potentially `https://` if using a proxy server configured for SSL connection *to the proxy itself*, though `http://` is common). This prefix defines how your script connects *to the proxy server*. The proxy then handles the connection to the final target URL (which could be HTTP or HTTPS).

Using IP Whitelisting in Code

If you opted for IP whitelisting instead of username/password authentication, the setup is slightly different:

  1. Whitelist your machine's IP in the Evomi dashboard.

  2. Obtain the correct host and port from your dashboard (e.g., `rp.evomi.com` and port `1000`).

Your Python script would then look like this:

import requests

# Replace with your Evomi endpoint and port (no username/password needed)
# Example for HTTP Residential Proxy with whitelisting:
evomi_proxy_url_whitelisted = "http://rp.evomi.com:1000"

# Define the proxies dictionary
proxy_config = {
    "http": evomi_proxy_url_whitelisted,
    "https": evomi_proxy_url_whitelisted,
}

# A test URL
target_url = "https://httpbin.org/ip"

try:
    # Make the GET request
    response = requests.get(target_url, proxies=proxy_config, timeout=10)
    response.raise_for_status()
    # Print the response
    print("Request successful! Response:")
    print(response.json())
except requests.exceptions.RequestException as e:
    print(f"An error occurred: {e}")

Whitelisting simplifies the code slightly and enhances security against credential leaks but requires managing authorized IPs. Choose the method that best fits your workflow and security needs.

Manual Proxy Rotation with Python Requests (If Needed)

As mentioned, Evomi's endpoints typically handle rotation for you, providing a new IP for each request or maintaining sticky sessions as configured in the dashboard. This is usually sufficient for most use cases.

However, you might encounter situations where you need finer control, perhaps when working with a specific list of static IPs (like our Static ISP proxies) or if using a provider that *doesn't* offer automatic rotation via endpoints. Knowing how to implement basic rotation logic in your script can be useful.

Here’s an example demonstrating how you might cycle through a predefined list of proxy configurations:

import requests
import random # To pick a random proxy

# Example list of proxy configurations (replace with your actual proxies)
# This might be useful if you have multiple sub-users or static IPs
proxy_details_list = [
    {"host": "rp.evomi.com", "port": "1000", "username": "user_a", "password": "password_a"},
    {"host": "rp.evomi.com", "port": "1000", "username": "user_b", "password": "password_b"},
    # Add more Evomi proxy configurations (e.g., static IPs) as needed
    # Or use whitelisted format if applicable:
    # {"host": "static-ip-1.evomi.com", "port": "12345"},
    # {"host": "static-ip-2.evomi.com", "port": "12345"},
]


def format_proxy_url(proxy_info):
    """Formats the proxy URL string from dictionary details."""
    if "username" in proxy_info and "password" in proxy_info:
        # Authenticated proxy
        return f"http://{proxy_info['username']}:{proxy_info['password']}@{proxy_info['host']}:{proxy_info['port']}"
    else:
        # Assuming IP whitelisted proxy
        return f"http://{proxy_info['host']}:{proxy_info['port']}"


def send_request_with_random_proxy(url, proxy_list):
    """Selects a random proxy from the list and attempts a request."""
    if not proxy_list:
        print("Proxy list is empty.")
        return None

    selected_proxy_info = random.choice(proxy_list)
    proxy_url = format_proxy_url(selected_proxy_info)
    proxy_config = {
        "http": proxy_url,
        "https": proxy_url,
    }

    print(f"Attempting request via proxy: {selected_proxy_info['host']}:{selected_proxy_info['port']}")
    try:
        response = requests.get(url, proxies=proxy_config, timeout=15) # Increased timeout slightly
        response.raise_for_status()
        print("Request successful!")
        return response.json()
    except requests.exceptions.Timeout:
        print(f"Timeout occurred with proxy {selected_proxy_info['host']}:{selected_proxy_info['port']}")
        # Optionally: remove the failing proxy from the list or implement retry logic
        return None
    except requests.exceptions.RequestException as e:
        print(f"Error with proxy {selected_proxy_info['host']}:{selected_proxy_info['port']}: {e}")
        # Optionally: handle specific errors differently
        return None


# Example usage:
target_url = "https://httpbin.org/ip"
result = send_request_with_random_proxy(target_url, proxy_details_list)

if result:
    print("Response content:")
    print(result)

This enhanced script takes a list of proxy details, formats the URL string correctly (handling both authenticated and whitelisted formats), randomly selects one for each request attempt, and includes basic error handling (like timeouts). This is a simple rotation strategy; more complex scenarios might involve round-robin selection, removing failing proxies, or more sophisticated retry mechanisms.

Troubleshooting Common Issues

When working with proxies in Python Requests, you might encounter a few common hiccups. Thankfully, most are manageable.

First, incorporating error handling, like the `try...except` blocks shown above, is crucial. It helps distinguish between issues with the target website (e.g., 404 Not Found, 500 Server Error) and problems with the proxy itself (e.g., connection errors, timeouts). Knowing the source of the error saves significant debugging time.

You'll also likely encounter blocks or CAPTCHAs, especially during web scraping. Even with perfectly integrated proxies, target websites employ detection mechanisms. Relying on your provider's (like Evomi's) automatic rotation is often the first line of defense. Additionally, consider:

  • Slowing down your request rate.

  • Mimicking real browser headers.

  • Managing cookies and sessions appropriately.

  • Using higher-quality proxies (like residential or mobile) that are less likely to be flagged.

If you run into persistent issues, checking your proxy provider's documentation or reaching out to their support team is always a good step. At Evomi, we pride ourselves on our responsive support and ethical proxy sourcing, aiming to provide a reliable service backed by Swiss quality standards.

Diving into Python Requests with Evomi Proxies

Integrating proxies using Python's Requests library is a pretty smooth process, thankfully, as the library has built-in support for it. Since Requests is a popular choice for tasks like web scraping, knowing how to plug in proxies is a fundamental skill.

This guide will walk you through using Evomi residential proxies with the Requests library. Keep in mind that the core concepts apply similarly to other proxy types, like datacenter or mobile proxies.

So, What's the Deal with Python Requests?

Python Requests is an HTTP library designed with simplicity and human-friendliness at its core. While Python has some built-in ways to handle HTTP, Requests offers a much more intuitive and streamlined experience. You can find more details in our overview of Python Requests.

Crucially for us, Requests directly supports basic proxy usage, making it a solid foundation for projects needing IP anonymity or rotation, such as web scraping. While some complex proxy authentication setups might require a little extra work, the basics are straightforward.

Its lightweight nature and efficiency also contribute to its popularity among developers. For many straightforward HTTP tasks, Requests is often the first tool reached for.

However, it does have a limitation: Requests doesn't natively handle asynchronous operations. For applications needing high concurrency (sending many requests simultaneously instead of one after another), this can be a drawback. While extensions exist, the lack of built-in async support might lead developers working on larger-scale projects to explore other libraries.

Getting Your Evomi Proxies Ready

First things first, you need the proxies themselves. While free proxies might seem tempting, they often come with significant downsides like poor performance, unreliability, or even security risks. We strongly advise using reputable providers.

At Evomi, we offer various proxy types to suit different needs, including:

  • Residential Proxies: Starting at $0.49/GB, ideal for mimicking real user behavior.

  • Mobile Proxies: From $2.2/GB, using mobile carrier IPs.

  • Datacenter Proxies: Highly affordable at $0.30/GB for speed.

  • Static ISP Proxies: Starting from $1/IP for stable, residential-like IPs.

To get started:

  1. Sign up for an account on the Evomi platform.

  2. Navigate to the product section (e.g., Residential Proxies) and choose a plan that suits your data needs. We even offer a completely free trial for Residential, Mobile, and Datacenter proxies so you can test them out!

  3. Once your plan is active, head to your Evomi dashboard. You'll find your proxy credentials and connection details there.

For integrating with Python Requests, you'll typically need the proxy details in the `user:pass@host:port` format. Your Evomi dashboard will provide the necessary components: your username, password, the proxy endpoint (like `rp.evomi.com` for residential), and the corresponding port (e.g., `1000` for HTTP on residential).

Alternative: IP Whitelisting

Evomi also supports IP whitelisting. Instead of using a username and password, you can authorize your own machine's IP address to use the proxies. You can find your current IP using a tool like our IP Geolocation Checker. Then, add this IP to the whitelist section in your Evomi dashboard.

This simplifies the connection string (just `host:port`) and prevents accidental credential leaks, especially if you share code publicly. However, you'll need to whitelist the IP of every machine you intend to use the proxies from.

Configuring Python Requests to Use Evomi Proxies

When you check your Evomi dashboard, you'll see our proxy endpoints (e.g., `rp.evomi.com`, `dc.evomi.com`, `mp.evomi.com`). You generally don't need a long list of individual proxy IPs because Evomi handles the IP rotation automatically on our end through these central endpoints. Just use the main endpoint provided for your chosen proxy type.

If you need an IP address to remain the same for a specific duration (a "sticky session"), you can usually configure this session length directly in your Evomi dashboard settings, rather than needing to manage it in your code.

Now, let's get coding. Open your preferred Python IDE (like PyCharm) and create a new project or file. First, ensure you have the Requests library installed. Open your terminal or command prompt and run:

With Requests installed, you can write a simple script to test the proxy integration. We'll send a request to a site that shows our IP address to confirm the proxy is working.

import requests

# Replace with your actual Evomi credentials and endpoint/port
# Example for HTTP Residential Proxy:
evomi_proxy_url = "http://YOUR_USERNAME:YOUR_PASSWORD@rp.evomi.com:1000"

# Define the proxies dictionary for Requests
proxy_config = {
    "http": evomi_proxy_url,
    "https": evomi_proxy_url, # Use the same proxy for HTTPS traffic
}

# A test URL that returns the request's IP address
target_url = "https://httpbin.org/ip"

try:
    # Make the GET request using the configured proxies
    response = requests.get(target_url, proxies=proxy_config, timeout=10)
    response.raise_for_status() # Raise an exception for bad status codes (4xx or 5xx)

    # Print the response content (which should show the proxy's IP)
    print("Request successful! Response:")
    print(response.json())

except requests.exceptions.RequestException as e:
    print(f"An error occurred: {e}")

This script defines the proxy connection string (make sure to replace the placeholders!), sets up the dictionary that Requests expects, and then makes a simple GET request through the proxy. Using an IP checker like `httpbin.org/ip` is handy because the response directly shows you the IP address seen by the target server, confirming your traffic is routed through the proxy.

Note that the proxy URL itself starts with `http://` (or potentially `https://` if using a proxy server configured for SSL connection *to the proxy itself*, though `http://` is common). This prefix defines how your script connects *to the proxy server*. The proxy then handles the connection to the final target URL (which could be HTTP or HTTPS).

Using IP Whitelisting in Code

If you opted for IP whitelisting instead of username/password authentication, the setup is slightly different:

  1. Whitelist your machine's IP in the Evomi dashboard.

  2. Obtain the correct host and port from your dashboard (e.g., `rp.evomi.com` and port `1000`).

Your Python script would then look like this:

import requests

# Replace with your Evomi endpoint and port (no username/password needed)
# Example for HTTP Residential Proxy with whitelisting:
evomi_proxy_url_whitelisted = "http://rp.evomi.com:1000"

# Define the proxies dictionary
proxy_config = {
    "http": evomi_proxy_url_whitelisted,
    "https": evomi_proxy_url_whitelisted,
}

# A test URL
target_url = "https://httpbin.org/ip"

try:
    # Make the GET request
    response = requests.get(target_url, proxies=proxy_config, timeout=10)
    response.raise_for_status()
    # Print the response
    print("Request successful! Response:")
    print(response.json())
except requests.exceptions.RequestException as e:
    print(f"An error occurred: {e}")

Whitelisting simplifies the code slightly and enhances security against credential leaks but requires managing authorized IPs. Choose the method that best fits your workflow and security needs.

Manual Proxy Rotation with Python Requests (If Needed)

As mentioned, Evomi's endpoints typically handle rotation for you, providing a new IP for each request or maintaining sticky sessions as configured in the dashboard. This is usually sufficient for most use cases.

However, you might encounter situations where you need finer control, perhaps when working with a specific list of static IPs (like our Static ISP proxies) or if using a provider that *doesn't* offer automatic rotation via endpoints. Knowing how to implement basic rotation logic in your script can be useful.

Here’s an example demonstrating how you might cycle through a predefined list of proxy configurations:

import requests
import random # To pick a random proxy

# Example list of proxy configurations (replace with your actual proxies)
# This might be useful if you have multiple sub-users or static IPs
proxy_details_list = [
    {"host": "rp.evomi.com", "port": "1000", "username": "user_a", "password": "password_a"},
    {"host": "rp.evomi.com", "port": "1000", "username": "user_b", "password": "password_b"},
    # Add more Evomi proxy configurations (e.g., static IPs) as needed
    # Or use whitelisted format if applicable:
    # {"host": "static-ip-1.evomi.com", "port": "12345"},
    # {"host": "static-ip-2.evomi.com", "port": "12345"},
]


def format_proxy_url(proxy_info):
    """Formats the proxy URL string from dictionary details."""
    if "username" in proxy_info and "password" in proxy_info:
        # Authenticated proxy
        return f"http://{proxy_info['username']}:{proxy_info['password']}@{proxy_info['host']}:{proxy_info['port']}"
    else:
        # Assuming IP whitelisted proxy
        return f"http://{proxy_info['host']}:{proxy_info['port']}"


def send_request_with_random_proxy(url, proxy_list):
    """Selects a random proxy from the list and attempts a request."""
    if not proxy_list:
        print("Proxy list is empty.")
        return None

    selected_proxy_info = random.choice(proxy_list)
    proxy_url = format_proxy_url(selected_proxy_info)
    proxy_config = {
        "http": proxy_url,
        "https": proxy_url,
    }

    print(f"Attempting request via proxy: {selected_proxy_info['host']}:{selected_proxy_info['port']}")
    try:
        response = requests.get(url, proxies=proxy_config, timeout=15) # Increased timeout slightly
        response.raise_for_status()
        print("Request successful!")
        return response.json()
    except requests.exceptions.Timeout:
        print(f"Timeout occurred with proxy {selected_proxy_info['host']}:{selected_proxy_info['port']}")
        # Optionally: remove the failing proxy from the list or implement retry logic
        return None
    except requests.exceptions.RequestException as e:
        print(f"Error with proxy {selected_proxy_info['host']}:{selected_proxy_info['port']}: {e}")
        # Optionally: handle specific errors differently
        return None


# Example usage:
target_url = "https://httpbin.org/ip"
result = send_request_with_random_proxy(target_url, proxy_details_list)

if result:
    print("Response content:")
    print(result)

This enhanced script takes a list of proxy details, formats the URL string correctly (handling both authenticated and whitelisted formats), randomly selects one for each request attempt, and includes basic error handling (like timeouts). This is a simple rotation strategy; more complex scenarios might involve round-robin selection, removing failing proxies, or more sophisticated retry mechanisms.

Troubleshooting Common Issues

When working with proxies in Python Requests, you might encounter a few common hiccups. Thankfully, most are manageable.

First, incorporating error handling, like the `try...except` blocks shown above, is crucial. It helps distinguish between issues with the target website (e.g., 404 Not Found, 500 Server Error) and problems with the proxy itself (e.g., connection errors, timeouts). Knowing the source of the error saves significant debugging time.

You'll also likely encounter blocks or CAPTCHAs, especially during web scraping. Even with perfectly integrated proxies, target websites employ detection mechanisms. Relying on your provider's (like Evomi's) automatic rotation is often the first line of defense. Additionally, consider:

  • Slowing down your request rate.

  • Mimicking real browser headers.

  • Managing cookies and sessions appropriately.

  • Using higher-quality proxies (like residential or mobile) that are less likely to be flagged.

If you run into persistent issues, checking your proxy provider's documentation or reaching out to their support team is always a good step. At Evomi, we pride ourselves on our responsive support and ethical proxy sourcing, aiming to provide a reliable service backed by Swiss quality standards.

Diving into Python Requests with Evomi Proxies

Integrating proxies using Python's Requests library is a pretty smooth process, thankfully, as the library has built-in support for it. Since Requests is a popular choice for tasks like web scraping, knowing how to plug in proxies is a fundamental skill.

This guide will walk you through using Evomi residential proxies with the Requests library. Keep in mind that the core concepts apply similarly to other proxy types, like datacenter or mobile proxies.

So, What's the Deal with Python Requests?

Python Requests is an HTTP library designed with simplicity and human-friendliness at its core. While Python has some built-in ways to handle HTTP, Requests offers a much more intuitive and streamlined experience. You can find more details in our overview of Python Requests.

Crucially for us, Requests directly supports basic proxy usage, making it a solid foundation for projects needing IP anonymity or rotation, such as web scraping. While some complex proxy authentication setups might require a little extra work, the basics are straightforward.

Its lightweight nature and efficiency also contribute to its popularity among developers. For many straightforward HTTP tasks, Requests is often the first tool reached for.

However, it does have a limitation: Requests doesn't natively handle asynchronous operations. For applications needing high concurrency (sending many requests simultaneously instead of one after another), this can be a drawback. While extensions exist, the lack of built-in async support might lead developers working on larger-scale projects to explore other libraries.

Getting Your Evomi Proxies Ready

First things first, you need the proxies themselves. While free proxies might seem tempting, they often come with significant downsides like poor performance, unreliability, or even security risks. We strongly advise using reputable providers.

At Evomi, we offer various proxy types to suit different needs, including:

  • Residential Proxies: Starting at $0.49/GB, ideal for mimicking real user behavior.

  • Mobile Proxies: From $2.2/GB, using mobile carrier IPs.

  • Datacenter Proxies: Highly affordable at $0.30/GB for speed.

  • Static ISP Proxies: Starting from $1/IP for stable, residential-like IPs.

To get started:

  1. Sign up for an account on the Evomi platform.

  2. Navigate to the product section (e.g., Residential Proxies) and choose a plan that suits your data needs. We even offer a completely free trial for Residential, Mobile, and Datacenter proxies so you can test them out!

  3. Once your plan is active, head to your Evomi dashboard. You'll find your proxy credentials and connection details there.

For integrating with Python Requests, you'll typically need the proxy details in the `user:pass@host:port` format. Your Evomi dashboard will provide the necessary components: your username, password, the proxy endpoint (like `rp.evomi.com` for residential), and the corresponding port (e.g., `1000` for HTTP on residential).

Alternative: IP Whitelisting

Evomi also supports IP whitelisting. Instead of using a username and password, you can authorize your own machine's IP address to use the proxies. You can find your current IP using a tool like our IP Geolocation Checker. Then, add this IP to the whitelist section in your Evomi dashboard.

This simplifies the connection string (just `host:port`) and prevents accidental credential leaks, especially if you share code publicly. However, you'll need to whitelist the IP of every machine you intend to use the proxies from.

Configuring Python Requests to Use Evomi Proxies

When you check your Evomi dashboard, you'll see our proxy endpoints (e.g., `rp.evomi.com`, `dc.evomi.com`, `mp.evomi.com`). You generally don't need a long list of individual proxy IPs because Evomi handles the IP rotation automatically on our end through these central endpoints. Just use the main endpoint provided for your chosen proxy type.

If you need an IP address to remain the same for a specific duration (a "sticky session"), you can usually configure this session length directly in your Evomi dashboard settings, rather than needing to manage it in your code.

Now, let's get coding. Open your preferred Python IDE (like PyCharm) and create a new project or file. First, ensure you have the Requests library installed. Open your terminal or command prompt and run:

With Requests installed, you can write a simple script to test the proxy integration. We'll send a request to a site that shows our IP address to confirm the proxy is working.

import requests

# Replace with your actual Evomi credentials and endpoint/port
# Example for HTTP Residential Proxy:
evomi_proxy_url = "http://YOUR_USERNAME:YOUR_PASSWORD@rp.evomi.com:1000"

# Define the proxies dictionary for Requests
proxy_config = {
    "http": evomi_proxy_url,
    "https": evomi_proxy_url, # Use the same proxy for HTTPS traffic
}

# A test URL that returns the request's IP address
target_url = "https://httpbin.org/ip"

try:
    # Make the GET request using the configured proxies
    response = requests.get(target_url, proxies=proxy_config, timeout=10)
    response.raise_for_status() # Raise an exception for bad status codes (4xx or 5xx)

    # Print the response content (which should show the proxy's IP)
    print("Request successful! Response:")
    print(response.json())

except requests.exceptions.RequestException as e:
    print(f"An error occurred: {e}")

This script defines the proxy connection string (make sure to replace the placeholders!), sets up the dictionary that Requests expects, and then makes a simple GET request through the proxy. Using an IP checker like `httpbin.org/ip` is handy because the response directly shows you the IP address seen by the target server, confirming your traffic is routed through the proxy.

Note that the proxy URL itself starts with `http://` (or potentially `https://` if using a proxy server configured for SSL connection *to the proxy itself*, though `http://` is common). This prefix defines how your script connects *to the proxy server*. The proxy then handles the connection to the final target URL (which could be HTTP or HTTPS).

Using IP Whitelisting in Code

If you opted for IP whitelisting instead of username/password authentication, the setup is slightly different:

  1. Whitelist your machine's IP in the Evomi dashboard.

  2. Obtain the correct host and port from your dashboard (e.g., `rp.evomi.com` and port `1000`).

Your Python script would then look like this:

import requests

# Replace with your Evomi endpoint and port (no username/password needed)
# Example for HTTP Residential Proxy with whitelisting:
evomi_proxy_url_whitelisted = "http://rp.evomi.com:1000"

# Define the proxies dictionary
proxy_config = {
    "http": evomi_proxy_url_whitelisted,
    "https": evomi_proxy_url_whitelisted,
}

# A test URL
target_url = "https://httpbin.org/ip"

try:
    # Make the GET request
    response = requests.get(target_url, proxies=proxy_config, timeout=10)
    response.raise_for_status()
    # Print the response
    print("Request successful! Response:")
    print(response.json())
except requests.exceptions.RequestException as e:
    print(f"An error occurred: {e}")

Whitelisting simplifies the code slightly and enhances security against credential leaks but requires managing authorized IPs. Choose the method that best fits your workflow and security needs.

Manual Proxy Rotation with Python Requests (If Needed)

As mentioned, Evomi's endpoints typically handle rotation for you, providing a new IP for each request or maintaining sticky sessions as configured in the dashboard. This is usually sufficient for most use cases.

However, you might encounter situations where you need finer control, perhaps when working with a specific list of static IPs (like our Static ISP proxies) or if using a provider that *doesn't* offer automatic rotation via endpoints. Knowing how to implement basic rotation logic in your script can be useful.

Here’s an example demonstrating how you might cycle through a predefined list of proxy configurations:

import requests
import random # To pick a random proxy

# Example list of proxy configurations (replace with your actual proxies)
# This might be useful if you have multiple sub-users or static IPs
proxy_details_list = [
    {"host": "rp.evomi.com", "port": "1000", "username": "user_a", "password": "password_a"},
    {"host": "rp.evomi.com", "port": "1000", "username": "user_b", "password": "password_b"},
    # Add more Evomi proxy configurations (e.g., static IPs) as needed
    # Or use whitelisted format if applicable:
    # {"host": "static-ip-1.evomi.com", "port": "12345"},
    # {"host": "static-ip-2.evomi.com", "port": "12345"},
]


def format_proxy_url(proxy_info):
    """Formats the proxy URL string from dictionary details."""
    if "username" in proxy_info and "password" in proxy_info:
        # Authenticated proxy
        return f"http://{proxy_info['username']}:{proxy_info['password']}@{proxy_info['host']}:{proxy_info['port']}"
    else:
        # Assuming IP whitelisted proxy
        return f"http://{proxy_info['host']}:{proxy_info['port']}"


def send_request_with_random_proxy(url, proxy_list):
    """Selects a random proxy from the list and attempts a request."""
    if not proxy_list:
        print("Proxy list is empty.")
        return None

    selected_proxy_info = random.choice(proxy_list)
    proxy_url = format_proxy_url(selected_proxy_info)
    proxy_config = {
        "http": proxy_url,
        "https": proxy_url,
    }

    print(f"Attempting request via proxy: {selected_proxy_info['host']}:{selected_proxy_info['port']}")
    try:
        response = requests.get(url, proxies=proxy_config, timeout=15) # Increased timeout slightly
        response.raise_for_status()
        print("Request successful!")
        return response.json()
    except requests.exceptions.Timeout:
        print(f"Timeout occurred with proxy {selected_proxy_info['host']}:{selected_proxy_info['port']}")
        # Optionally: remove the failing proxy from the list or implement retry logic
        return None
    except requests.exceptions.RequestException as e:
        print(f"Error with proxy {selected_proxy_info['host']}:{selected_proxy_info['port']}: {e}")
        # Optionally: handle specific errors differently
        return None


# Example usage:
target_url = "https://httpbin.org/ip"
result = send_request_with_random_proxy(target_url, proxy_details_list)

if result:
    print("Response content:")
    print(result)

This enhanced script takes a list of proxy details, formats the URL string correctly (handling both authenticated and whitelisted formats), randomly selects one for each request attempt, and includes basic error handling (like timeouts). This is a simple rotation strategy; more complex scenarios might involve round-robin selection, removing failing proxies, or more sophisticated retry mechanisms.

Troubleshooting Common Issues

When working with proxies in Python Requests, you might encounter a few common hiccups. Thankfully, most are manageable.

First, incorporating error handling, like the `try...except` blocks shown above, is crucial. It helps distinguish between issues with the target website (e.g., 404 Not Found, 500 Server Error) and problems with the proxy itself (e.g., connection errors, timeouts). Knowing the source of the error saves significant debugging time.

You'll also likely encounter blocks or CAPTCHAs, especially during web scraping. Even with perfectly integrated proxies, target websites employ detection mechanisms. Relying on your provider's (like Evomi's) automatic rotation is often the first line of defense. Additionally, consider:

  • Slowing down your request rate.

  • Mimicking real browser headers.

  • Managing cookies and sessions appropriately.

  • Using higher-quality proxies (like residential or mobile) that are less likely to be flagged.

If you run into persistent issues, checking your proxy provider's documentation or reaching out to their support team is always a good step. At Evomi, we pride ourselves on our responsive support and ethical proxy sourcing, aiming to provide a reliable service backed by Swiss quality standards.

Author

Michael Chen

AI & Network Infrastructure Analyst

About Author

Michael bridges the gap between artificial intelligence and network security, analyzing how AI-driven technologies enhance proxy performance and security. His work focuses on AI-powered anti-detection techniques, predictive traffic routing, and how proxies integrate with machine learning applications for smarter data access.

Like this article? Share it.
You asked, we answer - Users questions:
How does using Evomi proxies with Python Requests affect the overall speed and performance of my web scraping or automation script?+
Are there specific proxy connection errors from Evomi I should anticipate and handle explicitly in my Python Requests error handling, beyond a general RequestException?+
The article mentions Requests isn't async. What alternative Python HTTP libraries work well with Evomi proxies for high-concurrency tasks?+
How can I securely store my Evomi proxy credentials when using them in a Python Requests project, rather than hardcoding them?+
If I configure a sticky session in my Evomi dashboard, will Python Requests automatically maintain that same IP across multiple separate runs of my script?+

In This Article