Skip to content

Instantly share code, notes, and snippets.

@JayantGoel001
Created January 9, 2021 10:20
Show Gist options
  • Save JayantGoel001/721b764efeaa903be5fd8cf9baba2b27 to your computer and use it in GitHub Desktop.
Save JayantGoel001/721b764efeaa903be5fd8cf9baba2b27 to your computer and use it in GitHub Desktop.
Getting IP Address of any website using socket
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