0
我在Python中编写了一个简单的程序,它允许您查找URL的IP。我得到这个错误:Python:gethostbyname错误
File "wexec.py", line 40, in hell
ipname = socket.gethostbyname('http://%s' % (hcon))
socket.gaierror: [Errno 11004] getaddrinfo failed
现在,我不知道我做错了什么,但这里是我的功能代码:
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()
正如你所看到的。我打开一个到网站的HTTP连接,然后用urllibb打开URL,然后获得网站的IP。但正如你所看到的,我不确定我做错了什么。有人可以帮忙吗?