-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmonitoring.py
54 lines (33 loc) · 1.36 KB
/
monitoring.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
# Import requests (to download the page)
import requests
# Import BeautifulSoup (to parse what we download)
from bs4 import BeautifulSoup
# Import Time (to add a delay between the times the scape runs)
import time
# Import smtplib (to allow us to email)
import smtplib
while True:
url = "https://mounicmadiraju.blogspot.com/"
headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36'}
response = requests.get(url, headers=headers)
soup = BeautifulSoup(response.text, "lxml")
if str(soup).find("Google") == -1:
time.sleep(60)
continue
else:
msg = 'Subject: This is Mounic/'s script talking, CHECK GOOGLE!'
fromaddr = 'YOUR_EMAIL_ADDRESS'
toaddrs = ['AN_EMAIL_ADDRESS','A_SECOND_EMAIL_ADDRESS', 'A_THIRD_EMAIL_ADDRESS']
setup the email server,
server = smtplib.SMTP('smtp.gmail.com', 587)
server.starttls()
add my account login name and password,
server.login("YOUR_EMAIL_ADDRESS", "YOUR_PASSWORD")
print('From: ' + fromaddr)
print('To: ' + str(toaddrs))
print('Message: ' + msg)
send the email
server.sendmail(fromaddr, toaddrs, msg)
disconnect from the server
server.quit()
break