Getting Corona Virus (COVID-19) Stats Using Python

Intro

Install

from covid import Covid

covid = Covid()
covid.get_data()
[
{
'country': 'Mainland China',
'confirmed': 80756,
'deaths': 3136,
'recovered': 60096,
'latitude': 30.5928,
'longitude': 114.3055,
'last_update': 1582264984000
},
{
'country': 'Italy',
'confirmed': 9172,
'deaths': 463,
'recovered': 724,
'latitude': 43.0,
'longitude': 12.0,
'last_update': 1583777591000
},
...
from covid import Covid

covid = Covid()
sweden_cases = covid.get_status_by_country("sweden")
print(sweden_cases)
{
'country': 'Sweden',
'confirmed': 355,
'deaths': 0,
'recovered': 1,
'latitude': 63.0,
'longitude': 16.0,
'last_update': 1583893094000
}
from covid import Covid

covid = Covid()
countries = covid.list_countries()
print(countries)
[
"china",
"italy",
"iran",
"republic of korea",
...
]
confirmed = covid.get_total_confirmed_cases()
recovered = covid.get_total_recovered()
deaths = covid.get_total_deaths()

Conclusion

--

--

Software Developer

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store