本文共 829 字,大约阅读时间需要 2 分钟。
#!/usr/bin/python
import dns.resolver, os, httplib
iplist = []
appdomain = "cdsendmail.ecwise.com"def checkip(ip):
checkurl = ip + ":80"getcontent = ""httplib.socket.setdefaulttimeout(5)conn = httplib.HTTPConnection(checkurl)try: conn.request("GET","/",headers = {"host": appdomain}) r = conn.getresponse() getcontent = r.read(15) print(getcontent) finally: if getcontent == "
def getip(domain):
try:a = dns.resolver.query(domain, 'A')except Exception as E:print "dns resolve error"+str(E)return 0for i in a.response.answer:for j in i.items:iplist.append(j.address)print iplistreturn Trueif name == "main":
if getip(appdomain) and len(iplist) > 0:for ip in iplist:checkip(ip)else:print "dns resolve error!"转载于:https://blog.51cto.com/victor2016/2071553