Issue
On the page https://bittrex.com/api/v2.0/pub/Markets/GetMarketSummaries i am trying to parse the text that i pull with requests. The code i am using to pull the text is here
import requests
from bs4 import BeautifulSoup
link = 'https://bittrex.com/api/v2.0/pub/Markets/GetMarketSummaries'
html = requests.get('https://bittrex.com/api/v2.0/pub/Markets/GetMarketSummaries').text
print(html)
I can easy pull all the text from the page but now i want to parse it with bs4 so that it only gets the numbers of specific currency, such as ADX, or ADT. (Shown as "MarketCurrency":"ADX") I want it to be able to find the information such as the High, Low, Volume and the Last from the page without pulling all the other junk. So for example i input the code for the currency i want, ex: ADX and it then parses that text and prints just the numbers for the high, low, volume, and last of the day. Thanks for any help!
Solution
Actually, you're pretty close. As the comments say, the output is not HTML, it is JSON. Luckily python has some nice built in functionality for this. The following code will parse the JSON text output from the site as a native python dictionary (json_dict).
import requests
import json
link = 'https://bittrex.com/api/v2.0/pub/Markets/GetMarketSummaries'
raw_json = requests.get('https://bittrex.com/api/v2.0/pub/Markets/GetMarketSummaries').text
json_dict = json.loads(raw_json)
print(json_dict)
Answered By - somil
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.