seleniumwire-python中的空请求



我在Ubuntu 18.04中使用selenium wire来抓取请求标头,并使用Firefox驱动程序。但是driver.requests是空的。我怎么了?

from seleniumwire import webdriver
driver = webdriver.Firefox(executable_path=FireFoxDriverPath, seleniumwire_options={'port': 12345})
driver.get('https://stackoverflow.com/')
print(driver.requests)

结果是:

[]

Ubuntu设置、Firefox设置或我的代码有问题吗?

要打印请求,可以使用以下解决方案:

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']
)

相关内容

  • 没有找到相关文章

最新更新