Created
January 9, 2021 10:20
-
-
Save JayantGoel001/721b764efeaa903be5fd8cf9baba2b27 to your computer and use it in GitHub Desktop.
Getting IP Address of any website using socket
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket as sk | |
try: | |
hostname = sk.gethostname() | |
ip_address = sk.gethostbyname(hostname) | |
print("HostName : "+hostname) | |
print("IP Address : "+ip_address) | |
URL = input("Enter a URL:") | |
ip = sk.gethostbyname(URL) | |
print("IP Address for "+URL+" : "+ip) | |
except Exception as e: | |
print(e) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment