# 来自 Bright Data Web Unlocker

了解从以下产品的关键差异和迁移流程： **Bright Data Web Unlocker** 到 [**Oxylabs Web Unblocker**](https://oxylabs.io/products/web-unblocker). 查看示例代码片段和功能对比，确保平稳迁移。

## 功能对比

[**Oxylabs Web Unblocker**](https://oxylabs.io/products/web-unblocker) 提供 Bright Data Web Unlocker 中的大多数功能，以及若干独特能力。下表突出显示了两项服务的主要差异：

| 功能            | Bright Data Web Unlocker           | Oxylabs Web Unblocker               |
| ------------- | ---------------------------------- | ----------------------------------- |
| 代理端点          | brd.superproxy.io:33335            | unblock.oxylabs.io:60000            |
| API 端点        | <https://api.brightdata.com/wsapi> | 尚不支持（请使用 Web Scraper API 实现 API 功能） |
| 代理轮换          | 自动                                 | 自动                                  |
| 验证码绕过         | 支持                                 | 支持（基于 AI）                           |
| 定价            | 高级域名单独定价                           | 单一价格                                |
| 地理位置定向        | 支持                                 | 支持                                  |
| 移动端定向         | 支持                                 | 不支持                                 |
| 自定义请求头/Cookie | 支持                                 | 支持                                  |
| JS 渲染         | 自动                                 | 手动（控制更强）                            |
| 渲染能力          | HTML                               | HTML 和 PNG                          |
| 浏览器指令         | 不支持                                | 支持                                  |
| POST 请求       | 不支持                                | 支持                                  |
| 会话            | 不支持                                | 支持                                  |
| 自定义状态码        | 不支持                                | 支持                                  |

## 发起请求

### 基本请求格式差异

Bright Data 和 Oxylabs 请求的主要区别在于地理位置的处理方式。Bright Data 使用按区域划分的账户，而 Oxylabs 允许你通过在请求头中传递位置信息，立即使用所有位置的代理。

#### **Bright Data 示例**

```python
import pprint
import requests

username = 'brd-customer-<customer_id>-zone-<zone_name>-country-us'
password = '<zone_password>'
proxy_url = f'http://{username}:{password}@brd.superproxy.io:33335'

proxies = {
    'http': proxy_url,
    'https': proxy_url
}

headers = {}
url = "http://lumtest.com/myip.json"

response = requests.get(url, proxies=proxies, headers=headers)
pprint.pprint(response.json())
```

#### **Oxylabs 示例**

```python
import requests

# Use your Web Unblocker credentials here
USERNAME, PASSWORD = 'YOUR_USERNAME', 'YOUR_PASSWORD'

# Define proxy dict
proxies = {
  'http': f'http://{USERNAME}:{PASSWORD}@unblock.oxylabs.io:60000',
  'https': f'https://{USERNAME}:{PASSWORD}@unblock.oxylabs.io:60000',
}

headers = {
    'x-oxylabs-geo-location': 'United States'
}

response = requests.request(
    'GET',
    'https://ip.oxylabs.io/headers',
    verify=False,  # Ignore the SSL certificate
    proxies=proxies,
    headers=headers
)

print(response.text)
```

## Oxylabs Web Unblocker 的独特功能

### 持久会话

Oxylabs Web Unblocker 的一项独特功能是会话功能，允许你通过同一个代理发送多个请求。通过在请求中添加自定义会话 ID 请求头，会话最长可使用 10 分钟：

```python
headers = {
    'X-Oxylabs-Session-Id': '123randomString'
}

response = requests.get(
    'https://ip.oxylabs.io/location',
    verify=False,  # Required to ignore certificate
    proxies=proxies,
    headers=headers,
)
```

有关会话的更多信息，请查看 [**Web Unblocker Session 文档页面。**](/documentation/cn/gao-ji-dai-li-jie-jue-fang-an/web-unblocker/making-requests/session.md)

### POST 请求

与 Bright Data Web Unlocker 不同，Oxylabs Web Unblocker 支持向网页端点发送 POST 请求：

```python
data = {
    'Your POST JSON': 'data'
}

response = requests.post(
    'https://ip.oxylabs.io/location',
    verify=False,  # Required to ignore certificate
    proxies=proxies,
    json=data,
)
```

有关 POST 请求的更多详情，请参阅 [**Web Unblocker POST requests 文档。**](#post-requests) &#x20;

### JavaScript 渲染和浏览器指令

Oxylabs Web Unblocker 提供自定义浏览器指令功能，并带有无头浏览器模式，可将结果页面的 JavaScript 渲染为 HTML 文档或 PNG 截图。此外，在 Web Unblocker 中使用无头浏览器时，你可以定义在 JavaScript 渲染期间执行的自定义浏览器指令。

有关此功能的更多信息，请参阅 [**Web Unblocker Custom Browser Instructions 文档。**](/documentation/cn/gao-ji-dai-li-jie-jue-fang-an/web-unblocker/custom-browser-instructions.md)&#x20;

## 参数参考

以下是你可以与 Oxylabs Web Unblocker 一起使用的主要 [**参数和请求头**](/documentation/cn/gao-ji-dai-li-jie-jue-fang-an/web-unblocker/making-requests/headers.md) ：

| 参数                             | 描述                                   | 示例                           |
| ------------------------------ | ------------------------------------ | ---------------------------- |
| X-Oxylabs-Geo-Location         | 指定请求的地理位置                            | 'United States', 'Germany' 等 |
| X-Oxylabs-Session-Id           | 创建或继续指定 ID 的会话                       | '123randomString'            |
| X-Oxylabs-Render               | 设置为 'html' 或 'png' 时启用 JavaScript 渲染 | 'html', 'png'                |
| X-Oxylabs-Browser-Instructions | 用于渲染的自定义浏览器指令                        | 包含指令的 JSON                   |

## 迁移清单

1. 将你的代理端点从以下地址更新为 `brd.superproxy.io:33335` 到 `unblock.oxylabs.io:60000`
2. 将基于区域的地理位置替换为 `X-Oxylabs-Geo-Location` 请求头
3. 将身份验证凭据更新为你的 Oxylabs 代理用户名和密码
4. 添加 `verify=False` 到你的请求中，以忽略 SSL 证书验证
5. 利用 Oxylabs 的独特功能，如会话和 POST 请求


---

# 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/documentation/cn/gao-ji-dai-li-jie-jue-fang-an/web-unblocker/migration-guides/from-bright-data-web-unlocker.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.
