> ## Documentation Index
> Fetch the complete documentation index at: https://docs.zenrows.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Using ZenRows® Residential Proxies with Python (Requests)

> Integrate ZenRows Residential Proxies with the Python requests library for web scraping, including proxy setup and troubleshooting tips.

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:

```bash theme={null}
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.

<Steps>
  <Step title="Get Your Credentials">
    Navigate to the ZenRows Residential Proxy [Generator Page](https://app.zenrows.com/proxies/generator) to get your username, password, proxy domain, and port.
  </Step>

  <Step title="Configure the Proxy URL">
    If necessary, configure your proxy URL on the Generator Page following the guide on [Residential Proxies Setup](/residential-proxies/residential-proxies-setup). Your proxy URL should be in this format:

    ```plain theme={null}
    http://<YOUR_USERNAME>:<YOUR_PASSWORD>@superproxy.zenrows.com:1337
    ```

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

  <Step title="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.

    ```python scraper.py theme={null}
    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:

    ```json theme={null}
    {
        "origin": "your-residential-proxy-ip"
    }
    ```
  </Step>
</Steps>

## 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](https://app.zenrows.com/proxies/generator) 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:

```bash theme={null}
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](https://docs.zenrows.com/residential-proxies/features/protocol-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.

For further assistance, feel free to <a href="mailto:success@zenrows.com">contact us</a>. 😉
