首页 > 解决方案 > 如何从 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”的值。我该怎么做?感谢您的帮助。

参考图片在这里

标签: pythonweb-scraping

解决方案


这能解决您的问题吗?

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"])


推荐阅读