Find IP Address using Python
An Internet Protocol address (IP address) is a numerical label assigned to each device connected to a computer network that uses the Internet Protocol for communication.
Using python, we can find the IP address and Hostname. For this, we use the Socket module of python. Socket is in-built in python and can be imported without any installation.
Usage
Get IP and Hostname of a computer
import socket
HOST = socket.gethostname()
IP = socket.gethostbyname(HOST)
print(HOST)
print(IP)
Get IP of a website
import socket
print (socket.gethostbyname("www.google.com"))
If you would like to contribute to Hackzism you can also write an article and mail to hackzism.hack@gmail.com.
Your article will be published on our home page.
Comments
Post a Comment