共计 456 个字符,预计需要花费 2 分钟才能阅读完成。
python 中实现单线程绑定域名解析,具体方法如下:
import time
import socket
def ReadHost(file):
hosts=[]
...
return hosts
def SynResolve(fr):
hosts=ReadHost(fr)
IPs={}
for host in hosts:
try:
results=socket.getaddrinfo(host,None)
for result in results:
print host, result[4][0]
IPs[result[4][0]]=host
except Exception,e:
print e
file.close()
if __name__=='__main__':
start=time.time()
print 'starting at:',start
SynResolve('host')
print 'ending at:',time.time()-start
丸趣 TV 网 – 提供最优质的资源集合!
正文完