Reputation: 1603
I was coding a simple program in python that allows you to find the IP of the URL. I get this error:
File "wexec.py", line 40, in hell
ipname = socket.gethostbyname('http://%s' % (hcon))
socket.gaierror: [Errno 11004] getaddrinfo failed
Now i'm not sure what I did wrong but here is my functions code:
def hell():
hcon = raw_input(Fore.RED + Style.BRIGHT + "Website: ")
h1 = httplib.HTTPConnection('http://%s:80' % (hcon))
urlopen = urllib.urlopen('http://%s:80' % (hcon))
ipname = socket.gethostbyname('http://%s' % (hcon))
print(strftime("[%H:%M:%S]", gmtime()) + " Found IP: %d " % (ipname))
enter = raw_input("Press enter or any other key to continue.")
hell()
As you can see. I open a HTTP connection to the website and then I open the URL with urllibb and then I get the IP of the website. But as you can see, I'm not sure what i'm doing wrong. Can someone help?
Upvotes: 0
Views: 5344
Reputation: 156
socket.gethostbyname() only takes the domain name, so you need to drop the 'http://' from that call. I don't understand what calls to httplib and urllib are doing, but they seem unnecessary from this snippet.
Upvotes: 2