I'm using the following code:
import socket
ip_list = []
ais = socket.getaddrinfo("www.yahoo.com",0,0,0,0)
for result in ais:
ip_list.append(result[-1][0])
ip_list = list(set(ip_list))
Or using a comprehension as:
ip_list = list({addr[-1][0] for addr in socket.getaddrinfo(name, 0, 0, 0, 0)})
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…