mirror of https://github.com/openspug/spug
U 优化站点检测异常信息输出
parent
ed4822ead6
commit
f084a4dcce
|
@ -12,8 +12,10 @@ import requests
|
||||||
import logging
|
import logging
|
||||||
import json
|
import json
|
||||||
import time
|
import time
|
||||||
|
import re
|
||||||
|
|
||||||
logging.captureWarnings(True)
|
logging.captureWarnings(True)
|
||||||
|
regex = re.compile(r'Failed to establish a new connection: (.*)\'\)+')
|
||||||
|
|
||||||
|
|
||||||
def site_check(url, limit):
|
def site_check(url, limit):
|
||||||
|
@ -25,7 +27,11 @@ def site_check(url, limit):
|
||||||
return False, f'响应时间:{duration}ms'
|
return False, f'响应时间:{duration}ms'
|
||||||
return 200 <= res.status_code < 400, f'返回状态码:{res.status_code}'
|
return 200 <= res.status_code < 400, f'返回状态码:{res.status_code}'
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return False, f'异常信息:{e}'
|
error = e.__str__()
|
||||||
|
exps = re.findall(regex, error)
|
||||||
|
if exps:
|
||||||
|
error = exps[0]
|
||||||
|
return False, error
|
||||||
|
|
||||||
|
|
||||||
def port_check(addr, port):
|
def port_check(addr, port):
|
||||||
|
|
Loading…
Reference in New Issue