Created
March 14, 2020 14:50
-
-
Save ahmedazizkhelifi/dda4f62a8cc6e85d19de24d6de2ce232 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from win10toast import ToastNotifier | |
from bs4 import BeautifulSoup | |
import time | |
import requests | |
country = "Tunisia" | |
notification_duration = 10 | |
refresh_time = 60 #seconds | |
while True: | |
html_page = requests.get("https://www.worldometers.info/coronavirus/") | |
bs = BeautifulSoup(html_page.content, 'html.parser') | |
search = bs.select("div tbody tr td") | |
start = -1 | |
end = -1 | |
for i in range(len(search)): | |
if search[i].get_text().find(country) !=-1: | |
start = i | |
break | |
array = [] | |
for i in range(1,8): | |
try: | |
array = array + [int(search[start+i].get_text())] | |
except: | |
array = array + [0] | |
message = "Total infected = {}, New Case = {}, Total Deaths = {}, New Deaths {}, Recovred = {}, Active Case = {}, Serious Critical = {}".format(*array) | |
toaster = ToastNotifier() | |
toaster.show_toast("Coronavirus {}".format(country) , message, duration = notification_duration , icon_path ="icon.ico") | |
time.sleep(refresh_time) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment