使用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()