Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

parsing a json file that is changing every day

Here is my code.
What i need is to parse that json file every X minutes so i can have the latest data.

import requests
import json

response = requests.api.get('https://api.apify.com/v2/key-value-stores/3Po6TV7wTht4vIEid/records/LATEST?disableRedirect=true').content
response = json.loads(response)
daily_infected = response['dailyInfected']
txtdate = response['txtDate']

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I dont know if my answer is efficient for you, but as I understand, you just want data every X minutes

import requests
import json
import time

minutes = 5 # lets say if you want data every five minutes

response = requests.api.get('https://api.apify.com/v2/key-value- 
stores/3Po6TV7wTht4vIEid/records/LATEST?disableRedirect=true').content

while(True):
    response = json.loads(response)
    daily_infected = response['dailyInfected']
    txtdate = response['txtDate']
    time.sleep(minutes/60)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading