I'm using selenium-wire to scrape requests headers in Ubuntu 18.04 and using Firefox driver. But driver.requests
is empty. what's the problem with me?
from seleniumwire import webdriver
driver = webdriver.Firefox(executable_path=FireFoxDriverPath, seleniumwire_options={'port': 12345})
driver.get('https://stackoverflow.com/')
print(driver.requests)
and result is:
[]
Is there something wrong with Ubuntu settings or Firefox settings or my code?
To print the requests you can use the following solution:
from seleniumwire import webdriver
driver = webdriver.Firefox(executable_path=FireFoxDriverPath)
driver.get('https://stackoverflow.com/')
# Access requests via the `requests` attribute
for request in driver.requests:
if request.response:
print(
request.path,
request.response.status_code,
request.response.headers['Content-Type']
)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.