Is there a python-module that\'s doing the same stuff as nslookup does? I am planning to use nslookup on digging some information regarding the domain of a URL to be scrappe
Previous answers are correct but here is what I would use socket, it "provides access to the BSD socket interface. It is available on all modern Unix systems, Windows, MacOS, and probably additional platforms."
import socket
distinct_ips = []
# 0,0,0,0 is for (family, type, proto, canonname, sockaddr)
#change some_site.com to whatever your are looking up of course
socket_info = socket.getaddrinfo("some_site.com",0,0,0,0)
for result in socket_info:
ns_ip = result[4][0]
if distinct_ips.count(ns_ip)==0:
distinct_ips.append(ns_ip)
print(ns_ip)