> For the complete documentation index, see [llms.txt](https://doc.thordata.com/doc/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.thordata.com/doc/zh/proxies/ji-cheng-jiao-cheng/zhu-zhai-dai-li-ji-cheng/playwright.md).

# Playwright

#### 什么是Playwright？

[**Playwright**](https://playwright.dev/)由 Microsoft 构建，是一个 Node.js 库，透过单一 API，可以自动化在 Chromium、Firefox 和 WebKit 上运行的网站和 Web 应用程式。编写 JavaScript 程式码的开发人员可以使用这些 API 来建立新的浏览器页面、导航到 URL，然后与页面上的元素互动。此外，由于 Microsoft Edge 建置在开源 Chromium Web 平台上，Playwright 还可以自动化 Microsoft Edge。

<figure><img src="/files/TL3PEydfYLRRbRwouOj7" alt=""><figcaption></figcaption></figure>

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

{% stepper %}
{% step %}

### 安装Playwright

首先使用 npm、yarn 或 pnpm 安装 Playwright。或者，您也可以使用 VS Code 扩充功能开始并执行测试。

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

{% step %}

### 在Playwright中填入代理值

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

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

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

**代码示例：**

```
const playwright = require('playwright');
(async () => {
    for (const browserType of ['chromium', 'firefox', 'webkit']) {
        const browser = await playwright[browserType].launch({
            headless: false,
            proxy: {
                server: 'http://t.pr.thordata.net:9999',
                username: 'td-customer-USERNAME',
                password: 'PASSWORD'
            },
        });
        const context = await browser.newContext();
        const page = await context.newPage();
        await page.goto('https://ipinfo.thordata.com');
        await page.screenshot({ path: `${browserType}.png` });
        await browser.close();
    }
})();
```
