Finding Host Name and IP Address
September 26, 2022
# importing socket library
import socket
# http://www.pillalamarri.in/python/finding-host-name-and-ip-address/
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()
Posted in Python