python - 如何从 python 中的 response.text() 中提取值
问题描述
import pandas as pd
URL = "https://ftx.com/api/futures/ETH-PERP/stats"
response = requests.get(URL)
html=response.text
对于上面的代码,我想从 html 中提取“nextFundingRate”的值。我该怎么做?感谢您的帮助。
解决方案
这能解决您的问题吗?
import pandas as pd
import json
import requests
URL = "https://ftx.com/api/futures/ETH-PERP/stats"
response = requests.get(URL)
html = response.text
# SOLUTION
result = dict(json.loads(html))
print(result["result"]["nextFundingRate"])
推荐阅读
- reactjs - 重用 DOM 节点会导致巨大的累积布局变化 (CLS)
- javascript - 将两个数组映射并排序为一个
- excel - Excel 互操作在 Office 2007 和 Office 365 中提供不同的输出
- css - 以响应方式将中间内容移动到桌面侧边栏
- html - 如何在使用 Storm-crawler 抓取网页时排除带有 id/class、页眉和页脚部分的 HTMl 的特定 DIV?
- prometheus - Prometheus java 客户端和 Prometheus 服务器兼容性
- airflow - 气流任务设置为未在此池中排队的池
- excel - 从 Power Query 中的列中删除标点符号
- javascript - 寻找带有输入编号的 React Multiselect 组件
- react-native - 尝试从文件中解析模块`fs`