# Puppeteer

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

要将 Puppeteer 与 Oxylabs 集成 [**移动代理**](broken://pages/7c50b210d807de54753cf5eb3a868b41c8c528dd)**,** 请按照以下步骤操作：

**步骤 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[ **移动代理**](broken://pages/7c50b210d807de54753cf5eb3a868b41c8c528dd) 与 Puppeteer 集成。

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

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


---

# Agent Instructions: 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/mobile-proxies-guides/puppeteer-1.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.
