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
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
Very simple.
"http://yahoo.com" is not a host name. Try socket.gethostbyname('yahoo.com') :)
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'