网站即时解析:https://bittrex.com/api/v2.0/pub/Markets/GetMarketSummaries
我试图做到这一点,以便我只解析一个' MarketName'这是由用户选择的,然后在用户选择之后从“摘要”中提取相应的信息。喜欢High:Last:Low:Volume:等。
我的代码现在:
r = requests.get('https://bittrex.com/api/v2.0/pub/Markets/GetMarketSummaries').text
data = json.loads(r)
for item in data['result']:
CurrencyName = (item['Market']['MarketName'])
print(CurrencyName)
for item in data['result']:
LastPrice = (item['Summary']['Last'])
print(LastPrice)
这会拉动每个' MarketName'从整个api,以及每一个' Last'从每种货币的价格,我将如何使它只拉动用户想要/选择的那个。
答案 0 :(得分:1)
r = requests.get('https://bittrex.com/api/v2.0/pub/Markets/GetMarketSummaries').text
data = json.loads(r)
for item in data['result']:
if(item['Market']['MarketName'] == "USER_INPUT_HERE"):
LastPrice = (item['Summary']['Last'])
print(LastPrice)
这只会打印所选市场的最后价格。