# запрашиваем ip адрес для хоста
import socket
def get_ips_for_host(host):
try:
ips = socket.gethostbyname_ex(host)
except socket.gaierror:
ips=[]
return ips
ips = get_ips_for_host('yandex.ru')
for ip in ips[2]:
print(ip)
# запрашиваем ip адрес для хоста через определенный DNS
# pip install dnspython
import dns.resolver
host = "online.ru"
myResolver = dns.resolver.Resolver()
myResolver.nameservers = ['8.8.8.8', '8.8.4.4']
try:
myAnswers = myResolver.query(host, "A")
for rdata in myAnswers:
print (rdata)
except:
print ("Query failed")
import socket
def get_ips_for_host(host):
try:
ips = socket.gethostbyname_ex(host)
except socket.gaierror:
ips=[]
return ips
ips = get_ips_for_host('yandex.ru')
for ip in ips[2]:
print(ip)
# запрашиваем ip адрес для хоста через определенный DNS
# pip install dnspython
import dns.resolver
host = "online.ru"
myResolver = dns.resolver.Resolver()
myResolver.nameservers = ['8.8.8.8', '8.8.4.4']
try:
myAnswers = myResolver.query(host, "A")
for rdata in myAnswers:
print (rdata)
except:
print ("Query failed")
Комментариев нет:
Отправить комментарий