单个域名检测IP
import socket
def getIP(domain):
myaddr = socket.getaddrinfo(domain, 'http')
print(myaddr[0][4][0])
getIP("www1.baidu.com")
多个域名检测IP
读取CSV文件,检测IP
# coding=utf-8
import socket
def getIP(domain):
for domain in domain:
myaddr = socket.getaddrinfo(domain, 'http')
print(myaddr[0][4][0])
f=open('D://domain.csv','r')
f_read=f.read()
list_domain = f_read.split( )
getIP(list_domain)
版本2
#coding=utf-8
import socket
def getIP(domain):
for domain in domain:
myaddr = socket.getaddrinfo(domain, 'http')
print(myaddr[0][4][0])
getIP(['www.baidu.com','cchheenn.com'])
版本1
import socket
list_domain = ['www.baidu.com','cchheenn.com']
for domain in list_domain:
myaddr = socket.getaddrinfo(domain, 'http')
print(myaddr[0][4][0])