python - performance.getEntries() 没有得到更新
问题描述
我正在尝试从流媒体网站获取所有过去网络条目的 json。这是我在哪里看到这些网络条目的屏幕截图:
按下播放按钮后,网站会在一段时间内加载 .acc 文件(如 .mp3),大约每 11 秒一次。我正在运行一个脚本来获取由script =
. 该脚本最终在 250 个条目处停止更新,即使页面中继续加载 .acc 文件也是如此。这表现为print(current==last)
最终打印True
。我不知道为什么getEntries
无法识别加载超过 250 的项目。帮帮我?
代码:
script = "var performance = window.performance || window.mozPerformance || window.msPerformance || window.webkitPerformance || {}; var network = performance.getEntries() || {}; return network;"
url = 'https://www.iheart.com/live/kiss-108-1097/'
options = Options()
driver = webdriver.Firefox(options=options)
driver.get(url)
last= 0
for i in range(100):
time.sleep(11)
current = driver.execute_script(script)
print(current==last)
last=current
解决方案
根据对https://stackoverflow.com/a/45859018/6158174的回答,显然“通过性能条目获取网络请求只会在页面加载时提供网络请求,并且无法轮询后续的 async/ajax 调用” 。改用BrowserMob 代理 ( https://github.com/lightbody/browsermob-proxy )
推荐阅读
- tabulator - Tabulator v5 工具提示:cell.getData 不是函数?
- python - 在 Python 中使用 Elasticsearch 进行批量更新
- apache-spark - spark创建列表列的映射
- java - 这个 Spring Batch 作业调度 CRON 表达式是否正确?
- angular - 使用 Typescript 从组中设置选定的单选按钮
- docker-compose - 如何在 gitlab CI 中访问被测试的 dockerized 应用程序
- sparql - 无法过滤 ISO 639-2 的术语代码
- c - mingw64 gtk3 c 编译致命错误:在 ubuntu 20.04 上
- laravel - Laravel Storage Fake - 删除伪造的创建文件
- python - 我希望我的代码仅在结果与以前的结果不同且不再相同时打印