Created
March 24, 2020 12:00
-
-
Save yitsushi/94b2c60b7b3f2842015e316ded77cac4 to your computer and use it in GitHub Desktop.
covid-19 tracker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import sys | |
def check(name, row): | |
if name is None: | |
return True | |
if name == row['country'].lower(): | |
return True | |
if name == row['countryInfo']['iso2'].lower(): | |
return True | |
return False | |
res = requests.get('https://corona.lmao.ninja/countries').json() | |
labels = ['Name', 'Cases', 'Deaths', | |
'Recovered', 'Active', 'Critical', | |
'Cases / One Million'] | |
print('{0:25s} | {1:14s} | {2:13s} |' | |
' {3:10s} | {4:8s} | {5:8s} | {6:19s} |'.format(*labels)) | |
print('-'*117) | |
name = None | |
if len(sys.argv) > 1: | |
name = sys.argv[1].lower() | |
for row in res: | |
if check(name, row): | |
print('{country:25s} | {cases:6d} (+{todayCases:<4d}) |' | |
' {deaths:5d} (+{todayDeaths:<4d}) |' | |
' {recovered:10d} | {active:8d} | {critical:8d} |' | |
' {casesPerOneMillion:19d} |'.format(**row)) |
Author
yitsushi
commented
Mar 24, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment