我尝试将浏览器与wsendpoint连接起来:
(async () => {
const browser = await puppeteer.connect({browserWSEndpoint: 'ws://localhost:9222/devtools/page/eedbdd50-cd25-472d-a701-a0302d9ffe2f'});
const page = await browser.newPage();
await page.goto('https://www.google.com.tr');
})();
此代码可以打开新标签但不要转到链接。它给出了错误:
(node:2022) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Protocol error (Performance.enable): 'Performance.enable' wasn't found undefined
(node:2022) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
答案 0 :(得分:1)
试试这个:
const puppeteer = require('puppeteer');
puppeteer.connect({
browserWSEndpoint: 'your endpoint...'
}).then(async browser => {
const page = await browser.newPage();
await page.goto('https://www.google.com.tr');
});