小小代码片解析出一个域名下的多个IP,程序不够完善之处,多多交流。
import socket
name = raw_input('please input url:')
try:
myaddr = socket.getaddrinfo(name,'http')
for eachaddr in myaddr:
print eachaddr[4][0]
except socket.herror,e:
print "The Url may not exist!",e
raw_input('Type any key to exit!')
exit()
except socket.gaierror, e1:
print "The Url may not exist!"
raw_input('Type any key to exit!')
exit()
raw_input('Type any key to exit!');