gpt4 book ai didi

node.js - 如何使用 puppeteer wsendpoint 打开链接

转载 作者:太空宇宙 更新时间:2023-11-04 00:15:39 31 4
gpt4 key购买 nike

我尝试将浏览器与 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.

最佳答案

试试这个:

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');
});

关于node.js - 如何使用 puppeteer wsendpoint 打开链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47200100/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com