Ejemplo n.º 1
0
	smtp.connect(smtpserver)  
	smtp.login(username, password)  
	smtp.sendmail(sender, receiver, msg.as_string())  
	smtp.quit()  
def send_error(err):
	sender='*****@*****.**'
	receiver='*****@*****.**'
	subject='出错提醒-->'+err
	smtpserver='smtp.qq.com'
	username='******'
	password='******'
	text="服务出错,请尽快排查"+'\n'+'本次报错提示为:'+err
	msg=MIMEText(text,'plain','utf-8')
	msg['Subject'] = Header(subject,'utf-8')
	smtp = smtplib.SMTP()  
	smtp.connect(smtpserver)  
	smtp.login(username, password)  
	smtp.sendmail(sender, receiver, msg.as_string())  
	smtp.quit()

get_title_from_web(url)
try:  
	title_now=get_title_from_web(url)
	title_data=get_title_from_database()
	if title_now!=title_data[0]:
    	update_title(title_now)
    	send_message(title_now)
	print('update at'),printtime()
except Exception,e:
	send_error(str(e))