-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtracker.py
More file actions
33 lines (22 loc) · 1.03 KB
/
tracker.py
File metadata and controls
33 lines (22 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import requests
def get_corona_updates(country_):
url = "https://covid-193.p.rapidapi.com/statistics"
headers = {
'x-rapidapi-host': "covid-193.p.rapidapi.com",
'x-rapidapi-key': "17fd2932a3msh3bf2c273aca32f4p183c1bjsncb974202eeed"
}
response = requests.request("GET", url, headers=headers)
returned_data=response.json()['response']
data=''
for i in returned_data:
if(str(i['country']).lower()==country_.lower()):
data=i
break
new_cases=data['cases']['new']
active_cases = data['cases']['critical']
critical_cases = data['cases']['recovered']
recoverd_cases=data['cases']['total']
new_deaths=data['deaths']['new']
total_deaths=data['deaths']['total']
parsed_data="New cases : "+str(new_cases)+"\nActive cases : "+str(active_cases)+"\nTotal recovered : "+str(critical_cases)+"\nTotal cases: "+str(recoverd_cases)+"\nNew deaths : "+str(new_deaths)+"\nTotal deaths : "+str(total_deaths)
return parsed_data