标签:port ror check code key log odi conf 技术
前面已经写过Python3发邮件,Python发微信的文章了。直接导入即可。
#/usr/bin/env python #Guoyabin #-*- coding:utf-8 -*- import configparser,requests from time import sleep import WeChat,Mail class checkurl(object): def __init__(self,file): self.file=file self.cfg=configparser.ConfigParser() def cfg_load(self): self.cfg.read(self.file) self.allurl=self.cfg.items(‘yuming‘) self.reload=self.cfg.get(‘time‘,‘reload‘) self.mailto=self.cfg.items(‘mailto‘) def cfg_dump(self): while True: for k,v in self.allurl: try: res=requests.get(v) print(v,res.status_code) res.close() if res.status_code >= 400: errinfo=v+‘ ‘+str(res.status_code) wechat.send(‘@all‘,errinfo) for key,values in self.mailto: mail.send(values,errinfo,‘url访问失败报警‘) except: errinfo=v+‘ is error‘ print(errinfo) wechat.send(‘@all‘,errinfo) for key,values in self.mailto: mail.send(values,errinfo,‘url访问失败报警‘) sleep(int(self.reload)) if __name__ ==‘__main__‘: mail=Mail.sendmail() wechat=WeChat.WeChat() check=checkurl(‘yuming.ini‘) check.cfg_load() check.cfg_dump()
无耻的求一下赞助
标签:port ror check code key log odi conf 技术
原文地址:http://www.cnblogs.com/guoyabin/p/7241254.html