-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathCovid19_liveTracker.py
37 lines (34 loc) · 1.22 KB
/
Covid19_liveTracker.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
import requests
import bs4
country_name=input("Enter the Country name: ")
def covid19(country):
res = requests.get("https://www.worldometers.info/coronavirus/#countries")
soup = bs4.BeautifulSoup(res.text, 'lxml')
index = -1
data=soup.select('tr td')
for i in range(len(data)):
if data[i].text.lower()==country.lower():
index=i
break
for i in range(7):
if i == 0:
print("\nCountry name: "+str(data[i+index].text))
elif i == 1:
print("Total cases: "+str(data[i+index].text))
elif i == 2:
if data[i+index].text == '':
print("New cases: 0")
else:
print("New cases: "+str(data[i+index].text))
elif i == 3:
print("Total deaths: "+str(data[i+index].text))
elif i == 4:
if data[i+index].text == '':
print("New deaths: 0")
else:
print("New deaths: "+str(data[i+index].text))
elif i == 5:
print("Total Recovered: "+str(data[i+index].text))
elif i == 6:
print("Active cases: "+str(data[i+index].text),end='\n\n')
covid19(country_name)