Playwright
什麼是Playwright?
Playwright由 Microsoft 構建,是一個 Node.js 庫,透過單一 API,可以自動化在 Chromium、Firefox 和 WebKit 上運行的網站和 Web 應用程式。編寫 JavaScript 程式碼的開發人員可以使用這些 API 來建立新的瀏覽器頁面、導航到 URL,然後與頁面上的元素互動。此外,由於 Microsoft Edge 建置在開源 Chromium Web 平台上,Playwright 還可以自動化 Microsoft Edge。

下面為您介紹如何將Thordata與Playwright集成。
1
代碼示例:
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();
}
})();
Last updated
Was this helpful?