-
Notifications
You must be signed in to change notification settings - Fork 0
/
Web Scraping.py
75 lines (29 loc) · 873 Bytes
/
Web Scraping.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env python
# coding: utf-8
# # Desktop Notifier for Covid-19
# In[6]:
from urllib.request import urlopen , Request
from bs4 import BeautifulSoup as bs
from win10toast import ToastNotifier
# In[7]:
header = {"User-Agent":"Mozilla"}
req = Request("https://www.worldometers.info/coronavirus/country/india/" , headers = header)
html = urlopen(req)
# In[8]:
html.status
# In[9]:
obj = bs(html)
# In[15]:
new_cases = obj.find("li",{"class":"news_li"}).strong.text.split()[0]
# In[20]:
death = list(obj.find("li",{"class":"news_li"}).strong.next_siblings)[1].text.split()[0]
# In[21]:
# Notifier
notifier = ToastNotifier()
# In[22]:
message = "New Cases - "+new_cases +"\nDeath - "+death
# In[24]:
message
# In[25]:
notifier.show_toast(title="COVID-19 Update" , msg=message , duration=5 , icon_path =r"virus.ico")
# In[ ]: