Show DevBest [PY] GetIP

Sway

Ruby and Python are married.
Dec 19, 2010
194
76
This is a simple script I cooked up in Python in about 15 minutes to get the IP of a website. It is complete with exception handlers and bootleg loops (function calling here and there).

The purpose of this script is to retrieve the IP address of a website or hostname. It'll ask you if you wish to do it again, which then you will be able to enter the common responses to a question like that (yes, yeah, no, yup, ok, etc) and it will perform according to your response.

Source:


Snippet:
Code:
def getIP(): #this is the main part of the program
    try:
        host = input("Website: ")
        ip = socket.gethostbyname(host)
    except socket.gaierror:
        print("Invalid address!")
        again()
    finally: 
        print ("IP: %s" % ip)
        again() #this calls the function below

It is complete with comments and is to be used for educational purposes. You need Python 3.x to run this script. If you have any questions, comments, or concerns, don't hesitate to ask!
 

Sway

Ruby and Python are married.
Dec 19, 2010
194
76
@Wassim
Thanks.

@Stanleh
Code:
ip = socket.gethostbyname("http://google.ca")
print ip

I don't see how that contributes to the thread but I'll surely play along: putting the Python code above and your Java code side to side.. how is the Java code better?
 

IntactDev

Member
Nov 22, 2012
399
71
I feel bad for the mod who has to clean this thread :lol:

But really, this is a nice release. I've been looking to learn Python for sometime now. Good job
 

Markshall

Русский Стандарт
Contributor
Dec 18, 2010
2,638
2,393
Thread cleaned.

Who cares what language is better? Someone will need this and whether it gets used or not, probably only did it for educational purposes anyway.

Nice release.
 

Users who are viewing this thread

Top