-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
47 lines (32 loc) · 1.34 KB
/
main.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
from plyer import notification
import requests
import time
import sys,io
from bs4 import BeautifulSoup
def notify(title,message):
notification.notify(
title= title,
message = message,
app_icon = 'C://Users//Dell//Projects//Web_Scraping//Corona_Notification_Windows//corona.ico',
#app_icon= None
app_name = 'COVID-19 Report',
timeout = 15,
)
def getdata(url):
r = requests.get(url)
return r.text
if __name__ == "__main__":
while True:
data = getdata('https://www.worldometers.info/coronavirus/')
#print(data)
sys.stdout = io.TextIOWrapper(sys.stdout.buffer,'cp437','backslashreplace')
soup = BeautifulSoup(data, 'html.parser')
soup.prettify()# No need of this you can directly inspect the webpage
noofcases =soup.find_all("div",{'class' : 'maincounter-number'})[0].text
noofdeaths = soup.find_all("div",{'class' : 'maincounter-number'})[1].text
noofrecovery = soup.find_all("div",{'class' : 'maincounter-number'})[2].text
#print(soup.find_all("div",{'class' : 'maincounter-number'}))
messagef = f"Total Cases : {noofcases.strip()} \n Deaths : {noofdeaths.strip()}\n Recovered : {noofrecovery.strip()}"
notify('Global COVID-19 Report', messagef)
time.sleep(3600)
pass