Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Scraping into dictionary
#1
mv = {}
def woohoo():
    for i in json_data['result']:
        if i['MarketName'] not in mv:
            mv[i['MarketName']] = i['Volume']
        else:
            try:
                DifferenceInVolume = i['Volume'] / mv[i['MarketName']]
            except ZeroDivisionError:
                DifferenceInVolume = 0
                if DifferenceInVolume >= 1.01:
                    print(i['MarketName'])
My objective is to pull data from an API every ?/seconds and add it to a dictionary. I'm then trying to compare that dictionary with the previous scraped dictionary (n-1). This is what I have at the moment and it's only scraping one ['MarketName'] and ['Volume'] at a time rather than the entire list of ['MarketName'] and ['Volume'] in each run through the function.

I hope this makes sense. Any guidance would be much appreciated!
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020