-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
47 lines (36 loc) · 1.37 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
from bs4 import BeautifulSoup
import time
def notifyMe(title, message):
notification.notify(
title = title,
message = message,
app_icon = "C:\\Users\\cprit\\Desktop\\COVIDNOTIFY\\icon.ico",
timeout = 4
)
def getData(url):
r = requests.get(url)
return r.text
if __name__ == '__main__':
# notifyMe("Pritha", "Let's stop this corona virus pandemic together")
while True:
myHtmlData = getData('https://www.mohfw.gov.in/')
soup = BeautifulSoup(myHtmlData, 'html.parser')
# print(soup.prettify())
myDataStr = ""
for tr in soup.find_all('tbody')[0].find_all('tr'):
myDataStr += tr.get_text()
myDataStr = myDataStr[1:]
itemList = myDataStr.split("\n\n")
# print(itemList)
states = ['West Bengal', 'Karnataka']
for item in itemList[0:36]:
dataList = (item.split('\n'))
if dataList[1] in states:
print(dataList)
nTitle = 'Cases of Covid-19'
nText = f"State : {dataList[1]}\nActive Cases : {dataList[2]} & Cured : {dataList[3]}\nDeaths: {dataList[4]}\nTotal Cases : {dataList[5]}"
notifyMe(nTitle, nText)
time.sleep(2)
time.sleep(10)