This guide’ll show you how to integrate ZenRows® Residential Proxies with the Python requests library. You’ll learn how to install the necessary libraries, configure the proxy, and make your first request. We’ll also cover common mistakes, troubleshooting tips, and frequently asked questions about residential proxies.

Installing Required Libraries

First, you’ll need the requests library, which is widely used in Python, to make HTTP requests. If you don’t have it installed, use pip to install the library:

pip install requests

Once installed, you’re ready to integrate ZenRows Residential Proxies with requests.

Making Your First Request with ZenRows Residential Proxies

Follow the steps below to use ZenRows Residential Proxies with Python’s requests library.

1

Get Your Credentials

Navigate to the ZenRows Residential Proxy Generator Page to get your username, password, proxy domain, and port.

2

Configure the Proxy URL

If necessary, configure your proxy URL on the Generator Page following the guide on Residential Proxies Setup. Your proxy URL should be in this format:

http://<YOUR_USERNAME>:<YOUR_PASSWORD>@superproxy.zenrows.com:1337

Replace <YOUR_USERNAME> and <YOUR_PASSWORD> with your ZenRows proxy credentials.

3

Code Example

Here’s an example of sending a request through ZenRows Residential Proxies to httpbin.io/ip, which returns the IP address used for the request.

scraper.py
import requests

# Construct the proxy URL
proxy_url = "http://<YOUR_USERNAME>:<YOUR_PASSWORD>@superproxy.zenrows.com:1337"

# Set up proxies for requests
proxies = {
    "http": proxy_url,
    "https": proxy_url,
}

# Make a request through the Residential Proxy
try:
    response = requests.get("https://httpbin.io/ip", proxies=proxies)
    print(response.text)
except requests.exceptions.RequestException as e:
    print(f"An error occurred: {e}")

Expected output:

{
    "origin": "your-residential-proxy-ip"
}

Troubleshooting

Here are some common issues you may encounter when using ZenRows Residential Proxies with Python requests.

Incorrect Credentials

Make sure you are using the correct username, password, proxy host, and port. An incorrect combination of these values will result in an authentication error. If you’re unsure of your credentials, revisit the Generator Page to verify them.

Connection Refused or Blocked

If your requests are being blocked or refused, ensure:

  • You are correctly matching the protocol (http or https) and port (1337 or 1338).
  • The website you’re targeting is not actively blocking you. Some websites employ advanced anti-bot measures that detect proxies.

Invalid Proxy URL Format

Ensure the proxy URL format is correct. It should follow the structure:

http://username:password@proxy-host:port

If any component is missing or incorrectly formatted, the request will fail.

IP Rotation Settings

If you’re not seeing your IP change as expected, check your Sticky TTL settings on ZenRows. If the Sticky TTL is too long, the same IP will be used for multiple requests. Reduce the Sticky TTL to rotate IPs more frequently.

Frequently Asked Questions (FAQs)

For further assistance, feel free to contact us. 😉