selenium-wire
selenium-wire copied to clipboard
抓取不到请求头
from seleniumwire import webdriver
#capabilities = DesiredCapabilities.CHROME #capabilities['loggingPrefs'] = {'browser': 'ALL'} chrome_options = webdriver.ChromeOptions() #chrome_options.add_argument('--headless') chrome_options.add_experimental_option('useAutomationExtension',False) chrome_options.add_experimental_option("excludeSwitches",['enable-automation']) chrome_options.add_argument('--no-sandbox') chrome_options.add_argument('--ignore-certificate-errors-spki-list') chrome_options.add_argument('--ignore-ssl-errors')
chrome_options.add_experimental_option("debuggerAddress","127.0.0.1:9222")
driver = webdriver.Chrome( options=chrome_options) driver.get('https://www.baidu.com')
for request in driver.requests: if request.response: print(request.path)
The right field should be used in this case is headers
-print(request.path)
+print(request.response.headers)