> 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/integrations/cn/proxy-integrations/residential-proxies-guides/puppeteer.md).

# Puppeteer

[**Puppeteer**](https://developer.chrome.com/docs/puppeteer/) 是一个 Node 库，提供高级 API，可通过 DevTools Protocol 控制无头 Chrome 或 Chromium。

将 Puppeteer 与 Oxylabs 集成 [**住宅代理**](https://oxylabs.io/products/residential-proxy-pool)**,** 按照以下步骤操作，或观看此视频教程：

{% embed url="<https://youtu.be/9xyvfs0Qikw>" %}

**步骤 1。** 安装 Node.js 和你选择的代码编辑器。（如果你已经安装，请跳过这一步）

**步骤 2。** 创建一个 Node.js 项目并安装所需的软件包。&#x20;

**步骤 3。** 在 Puppeteer 中，填写该值，例如：

**代理服务器：** `pr.oxylabs.io:7777`

{% hint style="info" %}
你也可以使用随机或粘性国家/地区特定条目。例如，如果你输入 `us-pr.oxylabs.io:10000`下，你将获得一个美国出口节点。如果你输入 `10001` 在 **端口**，你将获得带有粘性会话的美国出口节点。你可以在 [**这里**](https://developers.oxylabs.io/proxies/residential-proxies/country-specific-entry-nodes#random-proxy-entry-nodes) 找到完整的国家/地区特定随机代理入口节点列表，以及粘性代理入口节点列表 - [**这里**](https://developers.oxylabs.io/proxies/residential-proxies/country-specific-entry-nodes#sticky-proxy-entry-nodes).
{% endhint %}

**步骤 4。** 在 `'page.authenticate'`，输入你的 Oxylabs 代理用户名和密码。

代码示例如下：

```
const puppeteer = require('puppeteer');
(async () => {
  const browser = await puppeteer.launch({
    headless: false,
    args: ['--proxy-server=pr.oxylabs.io:7777]  
});
  const page = await browser.newPage();
    await page.authenticate({
        username: 'USERNAME',
        password: 'PASSWORD'
    });
    await page.goto('https://ip.oxylabs.io');
    await page.screenshot({path: 'example.png'});
    await browser.close();
})();
```

就这样！你已经成功将 Oxylabs [**住宅代理**](https://oxylabs.io/products/residential-proxy-pool) 与 Puppeteer 集成。

如果你想进一步了解使用 Puppeteer 进行网页抓取，请阅读我们的 [**博客文章**](https://oxylabs.io/blog/puppeteer-tutorial).

查找原始的 Puppeteer 集成博客文章 [这里](https://oxylabs.io/resources/integrations/puppeteer).


---

# 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/integrations/cn/proxy-integrations/residential-proxies-guides/puppeteer.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.
