Demo关键技术
#!/usr/bin/env python
# A higher-level way
import dns.resolver
import time
resolver = dns.resolver.Resolver(configure=False)
resolver.nameservers = ['8.8.8.8']
time_start=time.time()
for i in range(50):
answer = resolver.query(str(i)+'ip.taobao.com', 'A')
time_end=time.time()
print('The nameservers are:')
for rr in answer:
print(rr)
print('totally cost',time_end-time_start)
#!/usr/bin/env python
# A higher-level way
import dns.resolver
import time
resolver = dns.resolver.Resolver(configure=False)
resolver.nameservers = ['223.5.5.5']
time_start=time.time()
all = 500
fp = open("subresult.txt","a")
rp = open("domains.txt","r")
for line in rp.readlines():
try:
sdomain = line.strip()
answer = resolver.query(sdomain,"A")
#print('The nameservers are:')
for rr in answer:
print(sdomain + " --- " + str(rr))
fp.write(sdomain + " --- " + str(rr) + "\n")
except:
print("Error when" + sdomain)
fp.close()
rp.close()
time_end=time.time()
print("totally cost : " ,time_end-time_start)
#print('totally cost' + str(all) ,time_end-time_start)
工程化设计