> 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/kuai-su-kai-shi/kuai-su-kai-shi-wu-tou-liu-lan-qi.md).

# 快速开始：无头浏览器

{% hint style="success" %}
已经熟悉基础知识？请查看 [无头浏览器文档](/products/cn/headless-browser.md).
{% endhint %}

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

{% stepper %}
{% step %}

### 设置与凭据

1. **创建账户：** 请在 [Oxylabs 仪表盘](https://dashboard.oxylabs.io/).
2. **选择套餐：** 在 Scraping Solutions → 无头浏览器 下选择套餐或免费试用。
3. **创建用户凭据：** 进入无头浏览器产品部分中的 Users 选项卡，创建用户名和密码（这些凭据用于 WebSocket Secure 身份验证）。
   {% endstep %}

{% step %}

### 你的第一条请求

Oxylabs 无头浏览器使用 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 = "ubc.oxylabs.io"
browser_url = f"wss://{username}:{password}@{endpoint}"

with sync_playwright() as p:
    # Connect to the remote Oxylabs browser
    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>

在无头浏览器中查找更多自定义选项 [文档](/products/cn/headless-browser.md#features).

### 下一步

* **想要监控您的浏览器？** 了解 [会话检查工具](/products/cn/headless-browser/hui-hua-jian-cha-yu-lu-zhi.md) 以可视化方式实时跟踪脚本与浏览器的交互。
* **脚本太慢？** 试试 [优化流量](/products/cn/headless-browser.md#recommended-setup) 以阻止不必要的资源加载。这将提高抓取速度并减少带宽消耗。
* **遇到错误或超时？** 查看 [故障排除指南](/products/cn/headless-browser/troubleshooting-guide.md) 以解决常见的 CDP 连接问题、库版本不匹配和执行超时。
* **在大型网站上遇到 "403 Forbidden" 吗？** 查看 [受限目标](/products/cn/headless-browser/restricted-targets.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, and the optional `goal` query parameter:

```
GET https://developers.oxylabs.io/documentation/cn/kuai-su-kai-shi/kuai-su-kai-shi-wu-tou-liu-lan-qi.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.
