Demo关键技术

  1. #!/usr/bin/env python
  2. # A higher-level way
  3. import dns.resolver
  4. import time
  5. resolver = dns.resolver.Resolver(configure=False)
  6. resolver.nameservers = ['8.8.8.8']
  7. time_start=time.time()
  8. for i in range(50):
  9. answer = resolver.query(str(i)+'ip.taobao.com', 'A')
  10. time_end=time.time()
  11. print('The nameservers are:')
  12. for rr in answer:
  13. print(rr)
  14. print('totally cost',time_end-time_start)
  1. #!/usr/bin/env python
  2. # A higher-level way
  3. import dns.resolver
  4. import time
  5. resolver = dns.resolver.Resolver(configure=False)
  6. resolver.nameservers = ['223.5.5.5']
  7. time_start=time.time()
  8. all = 500
  9. fp = open("subresult.txt","a")
  10. rp = open("domains.txt","r")
  11. for line in rp.readlines():
  12. try:
  13. sdomain = line.strip()
  14. answer = resolver.query(sdomain,"A")
  15. #print('The nameservers are:')
  16. for rr in answer:
  17. print(sdomain + " --- " + str(rr))
  18. fp.write(sdomain + " --- " + str(rr) + "\n")
  19. except:
  20. print("Error when" + sdomain)
  21. fp.close()
  22. rp.close()
  23. time_end=time.time()
  24. print("totally cost : " ,time_end-time_start)
  25. #print('totally cost' + str(all) ,time_end-time_start)

工程化设计

子域名获取工具.png