admin 管理员组

文章数量: 1184232

由于pyppeteer官方文档上说最好用适配浏览器来操作,因此这里选用chromium

翻文档,发现文档中这么写着
pyppeteer.browser.Browser
Connect to the existing chrome.
browserWSEndpoint option is necessary to connect to the chrome. The format is ws://{host}:\{host\}:{host}:{port}/devtools/browser/<id>. This value can get by wsEndpoint.
那么怎么找到这个 ws://{host}:\{host\}:{host}:{port}/devtools/browser/<id> 呢
首先在需要的浏览器上把端口改成没有占用的,这里大家都改成了9222,因此我也改成了9222

然后再浏览器上输入 localhost:9222/json, 就得到了我们需要的信息

代码中生成browser对象从 launcher改为connect,带上参数就ok

本文标签: 已有 浏览器 Pyppeteer