用seleniumwire获取网站的network中的url链接情况(url、headers)

from seleniumwire import webdriver  # Import from seleniumwire
import requests as req
executable_path = 'xxxdriver'
driver = webdriver.Firefox(executable_path=executable_path)
headers = None
driver.get(f'xxxxxx')
for request in driver.requests:
    if request.response:
        if request.url == 'xxxxxx':
            headers = request.headers
            break
driver.close()

你可能感兴趣的:(爬虫,python基础,python,selenium)