需求
获得参数为域名的字符串后
1. 判定是否为合规域名
2. 该域名是否活着(可访问)
实例
headers = { # 默认标头'User-Agent': '$','Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8','Accept-Language': 'en-US,en;q=0.5','Accept-Encoding': 'gzip,deflate','Connection': 'close','DNT': '1','Upgrade-Insecure-Requests': '1',
}def verify(url):if not re.search('http:|https:', url):url = 'http://' + urlreturn urldef isDomain(address):def is_domain_reachable(domain):try:response = requests.get(url=domain, headers=headers)if response.status_code == 200:print(response.text)return Trueexcept requests.exceptions.RequestException as e:return Falsedomain = verify(address)if is_domain_reachable(domain):return True, domainelse:return False, domainjudge, domain = isDomain(asset_info)
if not judge:return False
else:return True