发布时间:2019-08-28 09:07:53编辑:auto阅读(1593)
#!/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 == "<!DOCTYPE html ":
print ip + " [OK]"
else:
print ip + " [error]"
def getip(domain):
try:
a = dns.resolver.query(domain, 'A')
except Exception as E:
print "dns resolve error"+str(E)
return 0
for i in a.response.answer:
for j in i.items:
iplist.append(j.address)
print iplist
return True
if name == "main":
if getip(appdomain) and len(iplist) > 0:
for ip in iplist:
checkip(ip)
else:
print "dns resolve error!"
上一篇: python实现FTP上传下载
下一篇: python的安装
47881
46450
37333
34773
29347
26008
24961
19979
19582
18075
5821°
6449°
5962°
5988°
7093°
5937°
5981°
6472°
6437°
7818°