I've written a script in python to get different items from json response from a webpage. I've partially got success by collecting the name of different items. However, I wish to get the different price of it. When it comes to parse the corresponding values of each item, I've got stuck. Any help on this will be highly appreciated.
site address: web_link
Script I've tried with:
import requests res = requests.get("replace_with_above_url") for items in res.json(): for name in items: print(name) This is how the structure look like:
[{"BTC":{"sellPrice":711500,"buyPrice":711150,"lastTradePrice":711150}},{"XRP":{"sellPrice":76.7,"buyPrice":76.6,"lastTradePrice":76.6}},{"NEO":{"sellPrice":8769,"buyPrice":8651,"lastTradePrice":8769}},{"GAS":{"sellPrice":3140,"buyPrice":3105,"lastTradePrice":3105}},{"ETH":{"sellPrice":63500,"buyPrice":62450.01,"lastTradePrice":63500}},{"XLM":{"sellPrice":30.78,"buyPrice":30.61,"lastTradePrice":30.78}}] Output I'm having (only):
BTC XRP NEO Output I intend to get:
BTC 711500 711150 711150 XRP 76.7 76.6 76.6 so on ---
print(name,items[name]['sellPrice'],items[name]['buyPrice'],items[name]['lastTradePrice'])