#-*-conding:utf-8-*-importrequests,re,json,timefromrequestsimportReadTimeoutDing_url='https://oapi.dingtalk.com/robot/send?access_token=xxxxxxxxx'Ding_headers={"Content-Type":"application/json;charset=utf-8"}url='http://www.123.com.cn/'req=requests.get(url).texturl_list=re.findall('href="(.*?)"',req,re.S)urls=['http://www.123.com.cn/']forulinurl_list:ifulnotinurls:urls.append(ul)defstatus():foriinurls:if'show'ini:try:html_status=requests.head(url=i,timeout=30)status_codes=html_status.status_codecontent_print={str(status_codes):str(i)}#j=json.dumps(content_print)#TypeError:Objectoftype'function'isnotJSONserializabletime.sleep(1)except:status()returnstatus_codes,statusdefdatas(status):datass={"msgtype":"text","text":{"content":status},"at":{"atMobiles":[],"isAtAll":False}}String_textMsg=json.dumps(datass)req=requests.post(Ding_url,data=String_textMsg,headers=Ding_headers).textprint('发送内容:',String_textMsg)returnString_textMsgdefTorF(status_codes):#,titleifstatus_codes==200:datas(status)returndatas(status)num=1whilenum
添加回答
举报
0/150
提交
取消