Reputation: 272214
Very simple.
>>> import socket
>>> socket.gethostbyname('http://yahoo.com')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
socket.gaierror: [Errno -2] Name or service not known
Upvotes: 0
Views: 1198
Reputation: 10086
It is because, quite frankly, http://yahoo.com
is in no way a domain name, which gethostbyname
expects from you. http://yahoo.com
is an URL.
>>> import socket
>>> socket.gethostbyname("yahoo.com")
'69.147.114.224'
Upvotes: 2
Reputation: 22089
Very simple.
"http://yahoo.com" is not a host name. Try socket.gethostbyname('yahoo.com')
:)
Upvotes: 11