selenium已经登陆了 我怎么查看 网页 在fRequest xhr 的数据呢

在使用 Selenium 登录网页后,查看网页的 XHR 请求数据可以通过以下几种方法:

1. 使用浏览器开发者工具

  • **手动查看**:

  • 打开浏览器的开发者工具(按 F12 或右键点击页面元素选择"检查")。

  • 切换到"Network"标签页。

  • 刷新页面或执行相关操作,观察网络请求列表。

  • 找到 XHR 请求,点击请求查看详细信息,包括请求头、请求体、响应头和响应体等。

2. 使用 Selenium 结合浏览器性能日志

  • **配置浏览器以支持性能日志**:

```python

from selenium import webdriver

from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

import json

配置 Chrome 以支持性能日志

capabilities = DesiredCapabilities.CHROME

capabilities'goog:loggingPrefs' = {'performance': 'ALL'}

driver = webdriver.Chrome(desired_capabilities=capabilities)

打开网页

driver.get("https://v.lai.com/login")

获取性能日志

logs = driver.get_log('performance')

for entry in logs:

log = json.loads(entry'message')'message'

过滤出 XHR 请求

if log'method' == 'Network.requestWillBeSent':

request = log'params''request'

if request'url'.endswith('.xhr'):

print(request)

```

3. 使用代理工具

  • **使用 BrowserMob-Proxy**:

  • 安装并启动 BrowserMob-Proxy。

  • 配置 Selenium 使用该代理。

  • 通过代理工具捕获网络请求和响应数据。

这些方法可以帮助你在使用 Selenium 登录网页后,查看和分析网页的 XHR 请求数据。

相关推荐
devilnumber1 小时前
Java 递归算法 详解 + 核心要点 + 实战运用 + 避坑指南
java·开发语言·算法
大貔貅喝啤酒2 小时前
Python Requests库教程
自动化测试·python·requests库
copyer_xyf3 小时前
LangChain 调用 LLM
后端·python·agent
copyer_xyf3 小时前
Prompt 组织管理
后端·python·agent
asdfg12589633 小时前
JavaBean是什么?怎么理解?有什么用途?
java·开发语言
dsyyyyy11013 小时前
JavaScript变量
开发语言·javascript·ecmascript
shimly1234563 小时前
python3 uvicorn 是啥?
python
z落落4 小时前
C#WinForm 窗体切换与窗体传值(登录跳转案例)+WinForm 窗体传值(从上往下传、从下往上传)
开发语言·windows·c#
CTA量化套保4 小时前
期货量化程序 time.sleep 卡死:天勤单线程与 deadline 替代
python·区块链
allway24 小时前
How to Echo Multiline to a File in Bash [3 Methods]
开发语言·chrome·bash