如何通过Selenium Python使用CDP命令收集性能跟踪?
1 个回答
0
你可以通过SeleniumBase来获取Python/Selenium的性能日志:https://github.com/seleniumbase/SeleniumBase - (使用pip install seleniumbase
来安装)
下面是一个示例,展示了如何在绕过验证码的情况下获取性能日志:
from rich.pretty import pprint
from seleniumbase import Driver
driver = Driver(uc=True, log_cdp=True)
try:
driver.uc_open_with_reconnect("https://seleniumbase.io/apps/turnstile")
driver.uc_switch_to_frame("iframe")
driver.uc_click("span.mark")
driver.sleep(3)
pprint(driver.get_log("performance"))
finally:
driver.quit()