Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to get hostname from ip python

#This is how I got the hostname from the ip
import socket

# get input from user
input01 = input("
Type IP: ").upper() 

#gets information
output = socket.gethostbyaddr(str(input01))

#processes the information to only get the hostname
outputProceesed = str(output).split("'")[1::2]

#prints hostname
print(f"Their Hostname is {outputProceesed[0]}
")
 
PREVIOUS NEXT
Tagged: #hostname #ip #python
ADD COMMENT
Topic
Name
4+3 =