Skip to content

Instantly share code, notes, and snippets.

@harendra21
Created December 11, 2021 07:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harendra21/abc018ff57280d837bb2f3a0014cfb28 to your computer and use it in GitHub Desktop.
Save harendra21/abc018ff57280d837bb2f3a0014cfb28 to your computer and use it in GitHub Desktop.
# Get Ipaddress and Hostname of Website
# importing socket library
import socket
def get_hostname_IP():
hostname = input("Please enter website address(URL):")
try:
print (f'Hostname: {hostname}')
print (f'IP: {socket.gethostbyname(hostname)}')
except socket.gaierror as error:
print (f'Invalid Hostname, error raised is {error}')
get_hostname_IP()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment