运行域名列表获取IP地址

时间:2017-10-28 23:11:59

标签: python-3.x

我想运行" host domain.com"通过获取URL

UIColor.white

2 个答案:

答案 0 :(得分:0)

列表中的网址:

os.system("host %s | grep 'has address' | sort -u" % (url))

答案 1 :(得分:0)

enter code here
 #!/usr/bin/python
 import subprocess
 list = ("/root/cisco/indexlist.txt","r") 
 for hostname in list:
 p1 = subprocess.Popen(['host', hostname],stdout=subprocess.PIPE)
 p2 = subprocess.Popen(['grep', 'IP ADDRESS'], stdin=p1.stdout, stdout=subprocess.PIPE)
 p3 = subprocess.Popen(['sort','-u'],stdin=p2.stdout, stdout=subprocess.PIPE)
 print (p3.communicate()[0])