【原创】Selenium获取请求头、响应头
本文仅供学习交流使用,如侵立删! |
Selenium获取请求头、响应头
操作环境
- win10 、 mac
- Python3.9
- selenium、seleniumwire
selenium是没有办法直接获取请求的详细Headers,很多时候我们我们是需要提取相关的参数来做进一步使用比如token之类的,这里推荐使用一个SeleniumWire模块来达到目的
Selenium-wire模块介绍
Selenium-wire官方文档
安装:pip install selenium-wire
项目介绍
Selenium Wire 扩展了 Selenium 的 Python 绑定,让您可以访问浏览器发出的底层请求。 您编写代码的方式与编写 Selenium 的方式相同,但您会获得额外的 API 来检查请求和响应并动态更改它们。
Compatibilty
- Python 3.6+
- Selenium 3.4.0+
- Chrome, Firefox and Remote Webdriver supported