我想连接到我用启动命令启动的chrome浏览器
await launch(headless=False, \
executablePath ="C:/Program Files/Google/Chrome/Application/chrome.exe",\
args=["--remote-debugging-port=9222"])使用connect命令
browser=await pyppeteer.connect(browserURL='http://127.0.0.1:9222')但看起来这是不对的。
如果我使用命令行打开浏览器
chrome_path = 'C:/Program Files/Google/Chrome/Application/chrome.exe '
cmdCommand = chrome_path + " --remote-debugging-port=9222"
subprocess.Popen(cmdCommand.split(), stdout=subprocess.PIPE)那么pyppeteer.connect就可以正常工作了。
发布于 2021-11-16 19:47:30
无论您使用的是python、javascript还是任何其他工具,例如puppeteer-stealth包,您都需要首先启动,然后获取wsEndpoint并通过pyppeteer.connect连接它。
pup = await launch(headless=False, \
executablePath ="C:/Program Files/Google/Chrome/Application/chrome.exe",\
);
endpoint = pup.wsEndpoint()
pyppeteer.connect(browserWSEndpoint = endpoint )如果您试图通过指定--remote-debugging port进行连接,则该选项有一个拼写错误。
https://stackoverflow.com/questions/69966216
复制相似问题