打印dns查询
#!/usr/bin/python
import socket
def gethost_ex(host_ex):
hostname_ex,alias_ex,address_ex = socket.gethostbyname_ex(host_ex)
return hostname_ex,alias_ex,address_ex
def array_print(*arr):
for item in arr:
print ' ',item
print
for host in ["","",""]:
print host
try :
hostname,alias,address = gethost_ex(host)
except socket.error as e:
print 'error',e
continue
print ' HostName:',hostname
print ' Alias:'
array_print(*alias)
print ' Address:'
array_print(*address)
阅读(1064) | 评论(0) | 转发(0) |