Aar*_*vM4 5 python firefox google-chrome xmlhttprequest python-requests
我想在 python 中制作一个程序,打印出一个站点的所有 xhr 请求。
我可以使用检查工具执行此操作,方法是转到 Network -> XHR,但我想运行执行此操作的代码。
代码应该给出一个带有名称键的字典,以及带有相应请求 URL、请求方法、内容类型和远程地址的字典值。
例如:
aDict = {'randomfile.js?_=1581185731016': {'url': 'https://softwaresat.netlify.com/randomfile.js?_=1581185731016', 'method': 'GET', 'address': '104.248.60.43:443'}}
Run Code Online (Sandbox Code Playgroud)
小智 8
您可以使用 selenium-wire python 模块来获取对我的项目有帮助的网站的所有 xhr 调用。
安装模块
pip install selenium-wire
获取 google.com 的 xhr 请求的示例代码
from seleniumwire import webdriver # Import from seleniumwire
# Create a new instance of the Chrome driver
driver = webdriver.Chrome()
# Go to the Google home page
driver.get('https://www.google.com')
# Access requests via the `requests` attribute
for request in driver.requests:
if request.response:
print(
request.url
)
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
946 次 |
最近记录: |