SeleniumBase无法捕获Performance日志的问题求助
SeleniumBase无法捕获Performance日志的问题求助
大家好,我遇到了一个关于SeleniumBase捕获Performance日志的问题,想请教下各位:
之前我用undetected_chromedriver配合Selenium可以正常捕获页面的请求和响应日志,代码如下:
import undetected_chromedriver as uc capabilities = DesiredCapabilities.CHROME capabilities["goog:loggingPrefs"] = {"performance": "ALL"} driver = uc.Chrome(headless=False, desired_capabilities=capabilities) driver.get(url) time.sleep(5) logs_raw = driver.get_log("performance")
这段代码运行正常,能输出所有的请求和响应日志,但切换到无头模式后就失效了。于是我换成了SeleniumBase来实现,按照我的理解,log_cdp=True参数应该和goog:loggingPrefs的作用一致,但实际测试下来,不管是无头还是非无头模式,都拿不到任何日志。页面其实已经正常加载完成,验证码也成功绕过了,需要的数据都能看到,就是logs_raw输出为空。我的SeleniumBase代码如下:
from seleniumbase import Driver driver = Driver(uc=True, log_cdp=True, headless=True) driver.get(url) time.sleep(5) logs_raw = driver.get_log("performance") print(logs_raw)
我的环境信息:
- seleniumbase 4.33.7
- Google Chrome 131.0.6778.85
- Windows 11 系统下使用 WSL Ubuntu 22.04 LTS
有没有大佬知道我哪里操作错了呀?
备注:内容来源于stack exchange,提问作者Matteo
相关产品推荐
相关产品推荐

