socket.gethostbyname

socket.gethostbyname

Postby tantrick » Thu Apr 25, 2013 10:02 am

Hi guys,

I have a function

Code: Select all
def get_ip(host):
     try:
          ips=socket.gethostbyname(host)
          ip=str(ips[2])
     except socket.gaierror, err:
           ip=err
     return ip

#from the code
dip=get_ip(title)


I always end up getting [Errno -5] No address associated with hostname

some sample title values that go in are
http://www.morenovaepic.com
htttp://www.lochravenproject.org
tantrick
 
Posts: 2
Joined: Thu Apr 25, 2013 9:56 am

Re: socket.gethostbyname

Postby gratuitous_arp » Thu Apr 25, 2013 11:02 am

The hostname passed into gethostbyname should just be the host or domain name instead of a full URL. Try taking off the "http://" prefix, so an example title would look like this: "www.morenovaepic.com".
gratuitous_arp
 
Posts: 6
Joined: Tue Apr 16, 2013 11:10 pm

Re: socket.gethostbyname

Postby tantrick » Mon Apr 29, 2013 6:22 am

Thanks it worked

gratuitous_arp wrote:The hostname passed into gethostbyname should just be the host or domain name instead of a full URL. Try taking off the "http://" prefix, so an example title would look like this: "www.morenovaepic.com".
tantrick
 
Posts: 2
Joined: Thu Apr 25, 2013 9:56 am


Return to Networking

Who is online

Users browsing this forum: No registered users and 1 guest