在Puppeteer中连接浏览器 [英] Connecting Browsers in Puppeteer

查看:340
本文介绍了在Puppeteer中连接浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以将浏览器连接到puppeteer而不在puppeteer中实例化它?例如,像普通用户一样运行Chrome实例,然后通过代码将其连接到puppeteer实例?

Is it possible to connect a browser to puppeteer without instantiating it in puppeteer? For example, running an instance of chromium like a regular user and then connecting that to an instance of puppeteer in code?

推荐答案

答案是是"和否".

您可以使用 connect 函数:

const browserURL = 'http://127.0.0.1:21222';
const browser = await puppeteer.connect({browserURL});

但是,如果要使用这两行,则需要使用"--remote-debugging-port=21222参数启动Chrome.

But, if you want to use those 2 lines you need to launch Chrome with the "--remote-debugging-port=21222 argument.

这篇关于在Puppeteer中连接浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆