# 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-hk/dai-li/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.
