> 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/headless-browser.md).

# 无头浏览器

无头浏览器可让你运行并控制远程无头浏览体验，无需在本地或自有基础设施上管理它们的复杂性。它提供了一种无缝方式来执行基于浏览器的自动化、测试和网页抓取，无需处理浏览器设置、资源限制或网络访问问题。&#x20;

### 支持的库

无头浏览器可与任何支持以下内容的库配合使用 **Chrome DevTools Protocol (CDP)**. 这包括：

* [Playwright](https://playwright.dev/) （对于 Firefox，支持的 Playwright 版本为 1.51 和 1.56）
* [Puppeteer](https://pptr.dev/)
* 其他兼容 CDP 的自动化框架

### 浏览器选项

无头浏览器提供两种专用浏览器环境：

* [基于 Chrome 的浏览器](/products/cn/headless-browser/chrome.md) – 运行在专用服务器上的高性能远程浏览器，具备高级隐匿能力，并集成代理
* [基于 Firefox 的浏览器](/products/cn/headless-browser/firefox.md) （旧版）- Firefox 实现，内置隐私功能并集成代理。请注意，此环境即将弃用。

此外，无头浏览器还提供两项与位置相关的功能：

* 面向美国用户的性能优化，
* 用于国家、城市和州级定向的地理位置参数。

### **速率限制**

每个都有 **100 个并发会话** 并且每个浏览器最多可启动 **每秒 10 个会话** （Chrome 和 Firefox）。这可确保服务稳定性和性能。

如需为您的账户申请更高限额，请通过以下方式联系 Oxylabs 客户支持： [在线聊天](https://oxylabs.io/) 或 [电子邮件](mailto:support@oxylabs.io).

### 快速入门示例

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

```python
from playwright.sync_api import sync_playwright

username = "your-username"
password = "your-password"
endpoint = "ubc.oxylabs.io"
browser_url = f"wss://${username}:${password}@${endpoint}"

with sync_playwright() as p:
    browser = p.chromium.connect_over_cdp(browser_url)
    page = browser.new_page()
    page.goto('https://example.com')
    print(page.title())
    browser.close()
```

{% endtab %}

{% tab title="JavaScript（Playwright）" %}

```javascript
import { chromium } from 'playwright';

(async () => {
    const username = 'your-username';
    const password = 'your-password';
    const endpoint = 'ubc.oxylabs.io';
    const browserUrl = `wss://${username}:${password}@${endpoint}`;

    const browser = await chromium.connectOverCDP(browserUrl);
    const page = await browser.newPage();
    await page.goto('https://example.com');
    console.log(await page.title());
    await browser.close();
})();
```

{% endtab %}

{% tab title="JavaScript（Puppeteer）" %}

```javascript
import puppeteer from 'puppeteer';

(async () => {
  const username = 'your-username';
  const password = 'your-password';
  const endpoint = 'ubc.oxylabs.io';
  const browserUrl = `wss://${username}:${password}@${endpoint}`;

  const browser = await puppeteer.connect({
    browserWSEndpoint: browserUrl
  });
  const page = await browser.newPage();
  await page.goto('https://example.com');
  console.log(await page.title());
  await browser.close();
})();
```

{% 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:

```
GET https://developers.oxylabs.io/products/cn/headless-browser.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.
