使用selenium.webdriver.common.desired_capabilities获取浏览器日志

from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

caps = DesiredCapabilities.CHROME
caps['loggingPrefs'] = {'performance': 'ALL'}
driver = webdriver.Chrome(desired_capabilities=caps)
driver.get("your url")
logs = [json.loads(log['message'])['message']['params'] for log in driver.get_log('performance')]
#获取request请求信息
for log in logs:
    if 'request' in log:
        requestUrl = log['request']['url']

driver.quit()

  

posted on 2019-01-07 18:36  miss_林  阅读(4114)  评论(0编辑  收藏  举报

导航