-
Notifications
You must be signed in to change notification settings - Fork 0
/
watch_cat.py
47 lines (35 loc) · 965 Bytes
/
watch_cat.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
__author__ = 'celhipc'
import requests
import re
import smtplib
# Import the email modules we'll need
from email.mime.text import MIMEText
def ready(page, pattern):
if re.search(pattern, page):
return True
return False
def getWebpae(url):
r = requests.get(url, verify=False)
return r.text
def sendEmail(server, emailTo, url):
'''send email '''
content = 'The web site you are watch is changed, please visit:' + url
msg = MIMEText(content)
msg['Subject'] = "The web site is changed"
myEmail = ''
msg['From'] = myEmail
msg['To'] = emailTo
pswd =""
s = smtplib.SMTP(server, 25)
s.login(myEmail, pswd)
s.send_message(msg)
s.quit()
def main():
url = "https://tp.m-team.cc/preregistered.php"
pattern = "sorry"
server = 'smtp.seu.edu.cn'
emailto = ''
if not ready(getWebpae(url), pattern):
sendEmail(server, emailto, url)
if __name__ == '__main__':
main()