-
Notifications
You must be signed in to change notification settings - Fork 0
/
ContentAggregator_Covid19.txt
77 lines (64 loc) · 3.74 KB
/
ContentAggregator_Covid19.txt
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import datetime, time, os
td = datetime.date.today()
# create a webdriver object for chrome-option and configure
wait_imp = 10
CO = webdriver.ChromeOptions()
CO.add_experimental_option('useAutomationExtension', False)
CO.add_argument('--ignore-certificate-errors')
CO.add_argument('--start-minimized') #maximized
wd = webdriver.Chrome(r'E:\chromedriver\chromedriver.exe',options=CO)
# Format for printing output
print ("Connecting to Authentic News source, Please wait .....\n")
news_site = "https://news.google.com/topics/CAAqIggKIhxDQkFTRHdvSkwyMHZNREZqY0hsNUVnSmxiaWdBUAE?hl=en-IN&gl=IN&ceid=IN%3Aen"
print ("Date:",td.strftime("%b-%d-%Y"))
print ("--------------------------------------------------------------------------------------------")
print (" >>>>>>>>>>>>>>>>>>> INDIA's TOP 5 NEWS HEADLINES on CORONAVIRUS <<<<<<<<<<<<<< ")
print ("--------------------------------------------------------------------------------------------\n")
wd.get(news_site)
wd.implicitly_wait(wait_imp)
cov_news = wd.find_elements_by_tag_name('h3')
# To get top 5 news headlines
n_ind = 0
for news in cov_news:
print ('>> '+ news.text, end='\n')
n_ind += 1
if n_ind > 4: # Increase the number to get more top newsheadlines --> Replace 4 by any other value
break
print ('\n')
# For Coronavirus stats
site2 = "https://www.worldometers.info/coronavirus/country/india/"
site3 = "https://www.mohfw.gov.in/"
site4 = "https://www.grainmart.in/news/coronavirus-covd-19-live-cases-tracker-john-hopkins/" #Johns Hopkins stats
print ("--------------------------------------------------------------------------------------------")
print (" Getting CORONAVIRUS stats from various sources (India) ")
print ("--------------------------------------------------------------------------------------------\n")
print ("Source Name -- Total Case -- Recovered -- Death")
print ("___________ __________ _________ ______ Please wait .. while collecting data")
wd.get(site2)
wd.implicitly_wait(wait_imp)
c2 = wd.find_elements_by_class_name("maincounter-number")
total_2 = c2[0].text
Death_2 = c2[1].text
Recovered_2 = c2[2].text
print ("Worldometers {} {} {} ".format(total_2,Recovered_2,Death_2))
wd.get(site3)
wd.implicitly_wait(wait_imp)
total_3 = wd.find_element_by_xpath("/html/body/div/div/div/section[1]/div/div/div/div/ul/li[1]/strong")
Death_3 = wd.find_element_by_xpath("/html/body/div/div/div/section[1]/div/div/div/div/ul/li[3]/strong")
Recovered_3 = wd.find_element_by_xpath("/html/body/div/div/div/section[1]/div/div/div/div/ul/li[2]/strong")
print ("Government {} {} {} ".format(total_3.text,Recovered_3.text,Death_3.text))
wd.get(site4)
wd.implicitly_wait(wait_imp)
total_4 = wd.find_element_by_xpath("/html/body/div[1]/div[1]/div/div/div/main/div/div/section/div/div[2]/div[1]")
Death_4 = wd.find_element_by_xpath("/html/body/div[1]/div[1]/div/div/div/main/div/div/section/div/div[2]/div[1]")
Recovered_4 = wd.find_element_by_xpath("/html/body/div[1]/div[1]/div/div/div/main/div/div/section/div/div[2]/div[1]")
print ("Johns-Hopkins {} {} {} \n".format(total_4.text,Recovered_4.text,Death_4.text))
wd.get("https://www.who.int/emergencies/diseases/novel-coronavirus-2019")
wd.implicitly_wait(wait_imp)
w_total = wd.find_element_by_id("confirmedCases")
w_death = wd.find_element_by_id("confirmedDeaths")
total_c = wd.find_element_by_id("involvedCountries")
print("WHO-Global {} No-data {} \n" .format(w_total.text ,w_death.text))
print ("Total Countries affected: ", total_c.text)