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 请求数据。

相关推荐
默_笙3 天前
🍙 给每个请求过安检:FastAPI 是怎么把校验写进类型注解的
python
小羊没烦恼!3 天前
初探性能优化——2个月到4小时的性能提升
java·开发语言·windows·算法·c#
qq_426003963 天前
启动playwright录制codegen生成自动化测试脚本
python·自动化
虎头金猫3 天前
4K 视频总卡在公网带宽?用 N1 + OpenList 把网盘播放链路重新理顺
运维·服务器·网络·python·容器·beautifulsoup·pandas
长沙三为智能科技3 天前
家政小程序开发从0到上线:五阶段交付流程与验收清单
python
伞伞悦读3 天前
【第38期】Python 模块与包详解:import、from、模块搜索路径、包结构和 __init__
开发语言·python
只睡四小时3 天前
Canvas 弹道联机实战:700 行 + 固定时间步长
python·websocket·html5·游戏开发·canvas
C语言小火车3 天前
C/C++ 为什么需要编译器?
开发语言·c++
奇思妙想聪明勤奋的小羊3 天前
DeepAgents第5章:子Agent 与上下文隔离—让 Agent学会委派
人工智能·python·学习·语言模型
lpfasd1233 天前
2026年第38周GitHub趋势周报
python·科技·github