> For the complete documentation index, see [llms.txt](https://developers.oxylabs.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.oxylabs.io/products/cn/proxies/dedicated-datacenter-proxies/enterprise/proxy-rotator-optional.md).

# Proxy Rotator - 可选

Proxy Rotator 为你的企业版独享数据中心代理列表提供单一端点访问。通过会话控制，每次请求获取不同 IP。

此服务为可选；如果您想使用 Proxy Rotator，请联系您的客户经理以获取一个域名。

我们不直接连接到单个 IP，而是为您的已分配代理列表提供一个单一端点。每次请求时，端点都会获取一个不同的 IP。请参阅下面的示例，了解如何将该端点用作代理。

{% hint style="info" %}
该 [vm.oxylabs.io](http://vm.oxylabs.io) 域名仅为示例。请联系您的客户经理，让他们为您转发一个域名。
{% endhint %}

{% hint style="success" %}
Proxy Rotator 只能与端口 `60000`.
{% endhint %}

#### 代码示例

{% 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',
    代理={'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;

类 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 %}

### 使用 Proxy Rotator 进行会话控制

可以使用 Proxy Rotator 保持相同的 IP 地址。首先，你需要知道你的 Proxy Rotator 有多少个代理。然后添加 `--proxy-header "Proxy-Server: sXXX"` 标头到你的请求中，其中 `sXXX` 是代理的编号，例如， `s5` 或 `s2541`.

#### 代码示例

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

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

{% 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, [
    "代理服务器: 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'
        返回请求头


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;

类 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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
