# Puppeteer

#### 什么是Puppeteer？

[**Puppeteer**](https://developer.chrome.com/docs/puppeteer)是一个 JavaScript 函式库，它提供进阶 API 来透过 DevTools 协定或 WebDriver BiDi 控制 Chrome 或 Firefox。 Puppeteer 预设在无头（无可见 UI）中运行，但可以配置为在可见（「有头」）浏览器中运行。

<figure><img src="/files/22P5iQjnplx5XIthYS8q" alt=""><figcaption></figcaption></figure>

下面为您介绍如何将Thordata与Puppeteer集成。

{% stepper %}
{% step %}

### 安装Puppeteer

您必须建立 Puppeteer 项目，启动它，然后使用 npm 和 Puppeteer 安装 Puppeteer。

[**点击此处**](https://pptr.dev/guides/installation)查看詳細安裝教程
{% endstep %}

{% step %}

### 在Puppeteer中填入代理值

**服务器:** `t.pr.thordata.net:9999`

**代理账户:** `td-customer-USERNAME`

**代理密码:** `PASSWORD`
{% endstep %}
{% endstepper %}

**代码示例：**

```
const puppeteer = require('puppeteer');
(async () => {
  const browser = await puppeteer.launch({
    headless: false,
    args: ['--proxy-server=t.pr.thordata.net:9999]  
});
  const page = await browser.newPage();
    await page.authenticate({
        username: 'td-customer-USERNAME',
        password: 'PASSWORD'
    });
    await page.goto('https://ipinfo.thordata.com');
    await page.screenshot({path: 'example.png'});
    await browser.close();
})();
```


---

# 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://doc.thordata.com/doc/zh/proxies/ji-cheng-jiao-cheng/zhu-zhai-dai-li-ji-cheng/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.
