> 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/documentation/cn/kai-shi-shi-yong/quick-start-agent-browser.md).

# 快速开始：Agent Browser

只需几分钟，即可通过简单的分步指南开始使用 Oxylabs Agent Browser。

{% hint style="success" %}
已经熟悉基础知识了吗？查看 [Agent Browser 文档](https://developers.oxylabs.io/products/cn/agent-browser.md).
{% endhint %}

Oxylabs [Agent Browser](https://oxylabs.io/products/headless-browser) 是一个云托管的浏览器基础设施，可自动处理机器人流量控制系统、CAPTCHA 和代理轮换。它与 Playwright、Puppeteer 以及用于 AI 应用的 Model Context Protocol (MCP) 完全兼容。

{% stepper %}
{% step %}

### 设置与凭证

1. **创建账户：** 在以下位置注册： [Oxylabs 控制台](https://dashboard.oxylabs.io/).
2. **添加产品实例：** 点击 **+ 添加产品实例** 并在 Browsers 类别中选择 Agent Browser。
3. **设置：** 选择实例名称、产品使用限制（可选），并创建实例。
4. **获取凭证：** 在概览实例表中点击 Agent Browser 产品并获取你的凭证。

{% hint style="info" %}
要免费试用我们的 Agent Browser，领取 5 美元 [欢迎赠金](https://developers.oxylabs.io/documentation/cn/kong-zhi-mian-ban/ji-yu-ji-fen-de-ji-fei.md#free-credits-welcome-credit).
{% endhint %}
{% endstep %}

{% step %}

### 你的第一个请求

Oxylabs Agent Browser 使用 Chrome DevTools Protocol (CDP)。你可以使用 Playwright 或 Puppeteer 连接，而无需管理本地浏览器二进制文件。

**Python + Playwright 示例：**

1. 安装 Playwright： `pip install playwright`
2. 运行以下脚本（替换 `USERNAME` 和 `PASSWORD` 为你的凭证）：

```python
from playwright.sync_api import sync_playwright

username = "USERNAME"
password = "PASSWORD"
endpoint = "hb.oxylabs.io"
browser_url = f"wss://{username}:{password}@{endpoint}"

with sync_playwright() as p:
    # 连接到远程 Oxylabs 浏览器
    browser = p.chromium.connect_over_cdp(browser_url)
    page = browser.new_page()
    
    page.goto('https://oxylabs.io/')
    print(f"Page Title: {page.title()}")
    
    browser.close()
```

{% endstep %}
{% endstepper %}

### 自定义浏览器

你也可以使用查询参数直接通过连接 URL 传递指令：

<table><thead><tr><th width="138.5">参数</th><th width="172">示例</th><th>描述</th></tr></thead><tbody><tr><td><code>p_cc</code></td><td><code>?p_cc=US</code></td><td>将浏览器的流量路由到特定国家/地区。</td></tr><tr><td><code>p_device</code></td><td><code>?p_device=mobile</code></td><td>模拟特定设备类型。</td></tr><tr><td><code>session_name</code></td><td><code>?session_name=ses-1</code></td><td>创建粘性会话，以让你的远程浏览器实例在云端持续运行。</td></tr></tbody></table>

在 Agent Browser [文档中查找更多自定义选项](https://developers.oxylabs.io/products/cn/agent-browser.md#features).

### 下一步

* **想要监控你的浏览器？** 了解 [会话检查工具](https://developers.oxylabs.io/products/cn/agent-browser/session-inspection-and-recording.md) 以可视化方式实时跟踪你的脚本与浏览器的交互。
* **你的脚本太慢了吗？** 试试 [优化流量](https://developers.oxylabs.io/products/cn/agent-browser.md#recommended-setup) 以阻止不必要的资源加载。这将提高抓取速度并减少带宽消耗。
* **遇到错误或超时？** 访问 [故障排查指南](https://developers.oxylabs.io/products/cn/agent-browser/troubleshooting-guide.md) 以解决常见的 CDP 连接问题、库版本不匹配和执行超时。
* **在大型网站上遇到“403 Forbidden”了吗？** 查看 [受限目标](https://developers.oxylabs.io/products/cn/agent-browser/restricted-targets.md) 列表，查看哪些网站或服务被限制通过 Agent Browser 访问。


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://developers.oxylabs.io/documentation/cn/kai-shi-shi-yong/quick-start-agent-browser.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
