File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed
Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change 33# The datetime package is useful to manipulate dates.
44from datetime import date , timedelta
55
6- # To fetch the latest total confirmed cases number you need to pass a 24h window to the API.
7- # That's why you need to pass both yesterday's date and today's.
6+ # To fetch the latest total confirmed cases number you need to pass a 24h
7+ # window to the API. That's why you need to pass both yesterday's date
8+ # and today's.
89today = date .today ()
910yesterday = today - timedelta (days = 1 )
1011
1718# The response will be a list of results per day, in your case only 1 result.
1819response = requests .get (endpoint , params = params ).json ()
1920
20- # Finally, you need to traverse through the response and increment the `total_confirmed` variable
21- # with the total number of confirmed cases available that day, which is in the field `Cases`.
21+ # Finally, you need to traverse through the response and increment the
22+ # `total_confirmed` variable with the total number of confirmed cases
23+ # available that day, which is in the field `Cases`.
2224total_confirmed = 0
2325for day in response :
2426 cases = day .get ("Cases" , 0 )
You can’t perform that action at this time.
0 commit comments