Corona project(python)
from plyer import notification
import requests
from bs4 import BeautifulSoup
import time
def notifyMe(title,message):
notification.notify(
title = title,
message = message,
app_icon= "Desktop\corona Python\icon.ico",
timeout = 21
)
def getData(url):
r = requests.get(url)
return r.text
if __name__ == "__main__":
# notifyMe("Arman","Let stop the Spread of the virus together")
myHtmlData= getData("https://www.mohfw.gov.in/")
print(myHtmlData)
soup = BeautifulSoup(myHtmlData, 'html.parser')
# print(soup.prettify())
myDataStr=""
for tr in soup.find_all('tbody'):
myDataStr +=(tr.get_text())
myDataStr = myDataStr[1:]
# [1].find_all('tr')
itemlist= (myDataStr.split("\n\n"))
states = ['Andaman and Nicobar','Gujarat','West Bengal', ]
for item in itemlist [0:35]:
dataList=(item.split("\n"))
if dataList[2] in states:
print(dataList)
nTitle ='Number of Covin-19 Cases'
nText = f"State: {dataList[2]} \nActive Cases : {dataList[3]}\nCured: {dataList[4]} \nDeaths:{dataList[5]} "
notifyMe(nTitle,nText)
time.sleep(2)
Comments
Post a Comment