# Proxy Rotator - Opcional

Este servicio es opcional; si deseas usar Proxy Rotator, contacta a tu Account Manager para recibir un dominio.

En lugar de conectarnos a IP individuales, te proporcionamos un único endpoint para tu lista de proxies asignada. Con cada solicitud, el endpoint obtiene una IP diferente. Consulta el ejemplo siguiente para aprender a usar el endpoint como proxy.

{% hint style="info" %}
El [vm.oxylabs.io](http://vm.oxylabs.io) domain es solo un ejemplo. Contacta a tu Account Manager para que te reenvíen un domain.
{% endhint %}

{% hint style="success" %}
Proxy Rotator debe usarse solo con el puerto `60000`.
{% endhint %}

#### Ejemplos de código

{% tabs %}
{% tab title="cURL" %}

```shell
curl -x vm.oxylabs.io:60000 -U user1:pass1 https://ip.oxylabs.io/location
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
$query = curl_init('https://ip.oxylabs.io/location');
curl_setopt($query, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($query, CURLOPT_PROXY, 'http://vm.oxylabs.io:60000');
curl_setopt($query, CURLOPT_PROXYUSERPWD, "username:password");
$output = curl_exec($query);
curl_close($query);
if ($output) {
    echo $output;
}
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

response = requests.get(
    'https://ip.oxylabs.io/location',
    proxies={'http': 'http://user1:pass1@vm.oxylabs.io:60000',
            'https': 'http://user1:pass1@vm.oxylabs.io:60000'}
)
print(response.text)
```

{% endtab %}

{% tab title="C#" %}

```csharp
using System;
using System.Net;

class Example
{
    static void Main()
    {
        var proxy = new WebProxy
        {
            Address = new Uri($"http://vm.oxylabs.io:60000"),
            BypassProxyOnLocal = false,
            UseDefaultCredentials = false,
            Credentials = new NetworkCredential("username", "password")
        };

        var handler = new HttpClientHandler
        {
            Proxy = proxy,
        };

        HttpClient client = new HttpClient(handler);
        var task = Task.Run(async () =>
        {
            var response = await client.GetAsync("https://ip.oxylabs.io/location");
            var content = response.Content;
            var result = await content.ReadAsStringAsync();
            return result;
        });

        task.Wait();
        Console.WriteLine(task.Result);
    }
}
```

{% endtab %}
{% endtabs %}

### Control de sesión usando Proxy Rotator

Es posible mantener la misma dirección IP con Proxy Rotator. Primero, necesitarás saber cuántos Proxies tiene tu Proxy Rotator. Luego añade la `--proxy-header "Proxy-Server: sXXX"` cabecera a tu solicitud, donde `sXXX` es el número del proxy, por ejemplo, `s5` o `s2541`.

#### Ejemplos de código

{% tabs %}
{% tab title="cURL" %}

```shell
user1@machine:~$ curl -x vm.oxylabs.io:60000 -U user1:pass1 https://ip.oxylabs.io/location --proxy-header "Proxy-Server: s10"
1.2.30.40
user1@machine:~$ curl -x vm.oxylabs.io:60000 -U user1:pass1 https://ip.oxylabs.io/location --proxy-header "Proxy-Server: s10"
1.2.30.40
user1@machine:~$ curl -x vm.oxylabs.io:60000 -U user1:pass1 https://ip.oxylabs.io/location --proxy-header "Proxy-Server: s10"
1.2.30.40
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
$query = curl_init('https://ip.oxylabs.io/location');
curl_setopt($query, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($query, CURLOPT_PROXY, 'http://vm.oxylabs.io:60000');
curl_setopt($query, CURLOPT_PROXYUSERPWD, "username:password");
curl_setopt($query, CURLOPT_PROXYHEADER, [
    "Proxy-Server: s10",
]);

$output = curl_exec($query);
curl_close($query);
if ($output) {
    echo $output;
}
```

{% endtab %}

{% tab title="Python" %}

```python
import requests


class ProxyAdapter(requests.adapters.HTTPAdapter):
    def proxy_headers(self, proxy):
        headers = super(ProxyAdapter, self).proxy_headers(proxy)
        headers['Proxy-Server'] = 's10'
        return headers


s = requests.Session()
s.proxies = {'http': 'http://username:password@vm.oxylabs.io:60000',
             'https': 'http://username:password@vm.oxylabs.io:60000'}
s.mount('http://', ProxyAdapter())
s.mount('https://', ProxyAdapter())
response = s.get('https://ip.oxylabs.io/location')
print(response.text)
```

{% endtab %}

{% tab title="C#" %}

```csharp
using System;
using System.Net;

class Example
{
    static void Main()
    {
        var client = new WebClient();
        client.Proxy = new WebProxy("http://vm.oxylabs.io:60000");
        client.Proxy.Credentials = new NetworkCredential("user1", "pass1");

        client.Headers.Add("Proxy-Server", "s10");

        Console.WriteLine(client.DownloadString("https://ip.oxylabs.io/location"));
    }
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developers.oxylabs.io/products/es/proxies/dedicated-datacenter-proxies/enterprise/proxy-rotator-optional.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
