-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpycovid19.py
54 lines (34 loc) · 1.37 KB
/
pycovid19.py
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import requests
import json
class covid_data:
def __init__(self,country):
self.country = country
request = requests.get('https://corona-rest-api.herokuapp.com/Api/{}/'.format(self.country))
if not 'error' in json.loads(request.text):
response = json.loads(request.text)
self.response = response
else:
error_response = json.loads(request.text)['error']
raise Exception(error_response)
def cases(self):
return self.response['Success']['cases']
def todayCases(self):
return self.response['Success']['todayCases']
def deaths(self):
return self.response['Success']['deaths']
def todayDeaths(self):
return self.response['Success']['todayDeaths']
def recovered(self):
return self.response['Success']['recovered']
def active(self):
return self.response['Success']['active']
def critical(self):
return self.response['Success']['critical']
def casesPerOneMillion(self):
return self.response['Success']['casesPerOneMillion']
def deathsPerOneMillion(self):
return self.response['Success']['deathsPerOneMillion']
def totalTests(self):
return self.response['Success']['totalTests']
def testsPerOneMillion(self):
return self.response['Success']['testsPerOneMillion']