> For the complete documentation index, see [llms.txt](https://docs.ipwo.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ipwo.net/kai-fa-zhe-wen-dang/ai-agent-kai-fa/ru-he-zai-browser-use-zhong-pei-zhi-ipwo-dai-li.md).

# 如何在 Browser Use 中配置 IPWO 代理

Browser Use 是一个开源 AI Agent 框架，可让大语言模型直接操作浏览器完成网页浏览、数据采集和自动化任务。

在访问目标网站时，为 Browser Use 配置住宅代理可以帮助管理网络出口 IP，提高连接稳定性，并根据业务需求选择不同国家或地区的网络环境。

本文将介绍如何在 Browser Use 中配置 IPWO 住宅代理。

***

### 什么是 Browser Use？

Browser Use 是一个基于 Playwright 的 AI Agent 框架，通过连接 OpenAI、Claude、Gemini 等模型，让 AI 能够像真人一样操作浏览器。

常见应用场景包括：

* AI 网页浏览
* 自动化表单填写
* 数据采集
* 网站监控
* AI Agent 工作流
* 自动化测试

***

### 环境准备

开始之前，请确保已经准备：

* 拥有 [IPWO 住宅代理账号](/readme/zhu-ce-deng-lu.md)
* [获取代理用户名和密码](/kai-fa-zhe-wen-dang/kuai-su-kai-shi/huo-qu-dai-li-xin-xi.md)
* 获取代理服务器地址和端口
* OpenAI、Claude 或 Gemini API Key

示例代理信息：

```
Host: us.ipwo.net
Port: 7878

Username: username
Password: password
```

***

### 安装 Browser Use

安装 Browser Use：

```bash
pip install browser-use
```

安装 Playwright 浏览器：

```bash
playwright install
```

***

### 在 Browser Use 中配置代理

Browser Use 底层使用 Playwright，因此可以直接使用 Playwright 的代理配置功能。

示例：

```python
from browser_use import Agent
from browser_use.browser.browser import Browser

browser = Browser(
    proxy={
        "server": "http://us.ipwo.net:7878",
        "username": "username",
        "password": "password"
    }
)

agent = Agent(
    task="Search for the latest AI news",
    browser=browser
)

agent.run()
```

启动后，所有浏览器流量都会通过代理节点访问目标网站。

***

### 指定国家节点

如果您使用国家定向代理，可以在用户名中指定目标国家。

示例：

```python
browser = Browser(
    proxy={
        "server": "http://us.ipwo.net:7878",
        "username": "username_country_us",
        "password": "password"
    }
)
```

此时 Browser Use 将通过美国出口 IP 访问网站。

***

### 与 OpenAI 配合使用

```python
from browser_use import Agent
from browser_use.browser.browser import Browser
from langchain_openai import ChatOpenAI

browser = Browser(
    proxy={
        "server": "http://us.ipwo.net:7878",
        "username": "username",
        "password": "password"
    }
)

agent = Agent(
    task="Find the latest proxy industry news",
    llm=ChatOpenAI(
        model="gpt-4o"
    ),
    browser=browser
)

agent.run()
```

***

### 与 Claude 配合使用

```python
from browser_use import Agent
from browser_use.browser.browser import Browser

browser = Browser(
    proxy={
        "server": "http://us.ipwo.net:7878",
        "username": "username",
        "password": "password"
    }
)

agent = Agent(
    task="Summarize the homepage content",
    browser=browser
)

agent.run()
```

代理配置方式保持一致。

***

### [验证代理](/kai-fa-zhe-wen-dang/kuai-su-kai-shi/kuai-su-yan-zheng.md)是否生效

启动 Browser Use 后，可以访问以下网站验证出口 IP：

```
https://ipinfo.io
```

或者：

```
https://whatismyipaddress.com
```

也可以使用命令行测试：

```bash
curl -x "us.ipwo.net:7878" \
-U "username:password" \
ipinfo.io
```

如果返回代理 IP 信息，则说明代理配置正常。

***

### 常见问题

### Browser 无法启动

请检查：

```bash
playwright install
```

是否已成功执行。

***

#### Connection Timeout

可能原因：

* 网络无法访问代理节点
* 防火墙限制连接
* 代理账号失效

建议先使用 curl 测试代理连接。

***

#### Proxy Authentication Failed

通常表示：

* 用户名错误
* 密码错误
* 代理认证格式错误

请检查代理配置中的：

```
server
username
password
```

是否填写正确。

***

#### 网站仍然显示本地 IP

请确认：

* Browser 实例已正确配置 proxy 参数
* 没有其他浏览器实例绕过代理
* Browser Use 已重新启动

***

### 最佳实践

* 长时间运行的 Browser Use Agent 建议使用 Sticky Session。
* 针对数据采集任务，可结合 IP 轮换功能降低封禁风险。
* 不同 Agent 建议使用独立 Session。
* 对于 Google、Amazon、TikTok 等高风控网站，建议使用住宅代理而非数据中心代理。
* 在 Docker 或云服务器环境中部署时，建议统一管理代理配置。

***

### 相关阅读

完成 Browser Use 代理配置后，您可能还需要：

* [OpenAI SDK 使用代理](/kai-fa-zhe-wen-dang/ai-agent-kai-fa/ru-he-zai-openai-sdk-zhong-shi-yong-ipwo-dai-li.md)
* [Claude API 使用代理](/kai-fa-zhe-wen-dang/ai-agent-kai-fa/ru-he-zai-claude-api-zhong-shi-yong-ipwo-dai-li.md)
* [Gemini API 使用代理](/kai-fa-zhe-wen-dang/ai-agent-kai-fa/ru-he-zai-gemini-api-zhong-shi-yong-ipwo-dai-li.md)
* [LangChain 使用住宅代理](/kai-fa-zhe-wen-dang/ai-agent-kai-fa/ru-he-zai-langchain-xiang-mu-zhong-pei-zhi-ipwo-dai-li.md)
* [获取和配置住宅代理](/kai-fa-zhe-wen-dang/kuai-su-kai-shi/huo-qu-dai-li-xin-xi.md)
* [如何检测代理是否生效](/dai-li-jian-ce-yu-yin-si-an-quan/ru-he-jian-ce-dai-li-shi-fou-sheng-xiao.md)
* [407 Proxy Authentication Required](/kai-fa-zhe-wen-dang/chang-jian-cuo-wu/407-proxy-authentication-required.md)
* [超时 Timeout](/kai-fa-zhe-wen-dang/chang-jian-cuo-wu/chao-shi-timeout.md)


---

# 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:

```
GET https://docs.ipwo.net/kai-fa-zhe-wen-dang/ai-agent-kai-fa/ru-he-zai-browser-use-zhong-pei-zhi-ipwo-dai-li.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.
