DEV Community

Cover image for Track Anyone's IP Address using Python
Prakash Singh
Prakash Singh

Posted on

Track Anyone's IP Address using Python

Using this technique, you can make your own IP Tracker.

At first, download python in your system.

Step 1 : Add Dependencies

import os
import urllib2
import json
Enter fullscreen mode Exit fullscreen mode

OS Module : It will be used to interact with Operating System.


urllib2 Module : It will be used to handle "urls".


json(JavaScript Object Notation) Module : It will be used to store and exchange data.

Step 2 : Take Raw Input From User (Tageted IP)

ip = input("What is your target IP: ")
Enter fullscreen mode Exit fullscreen mode

Step 3 : Enter URL, whose api we are using

url = "http://ip-api.com/json/"
Enter fullscreen mode Exit fullscreen mode

Step 4 : Get HttpResponse in a variable

response=urllib2.urlopen(url+ip)
Enter fullscreen mode Exit fullscreen mode

Step 5 : Get Data from response in a variable

data=response.read()
Enter fullscreen mode Exit fullscreen mode

Step 6 : Get Data in JSON form in a variable

values=json.loads(data)
Enter fullscreen mode Exit fullscreen mode

Step 7 : Showcase the Informations

print("IP: "+values["query"])
print("City: "+values["city"])
print("ISP: "+values["isp"])
print("Country: "+values["country"])
print("Region: "+values["region"])
print("Timezone: "+values["timezone"])
Enter fullscreen mode Exit fullscreen mode

Full Code : Link

Top comments (2)

Collapse
 
v3ss0n profile image
Phyo Arkar Lwin

useless since it requeires thirdparty website.

Collapse
 
prkskrs profile image
Prakash Singh • Edited

thank u sir. i really appreciate your comment. but here i am trying to make people aware about python's library and interesting things people can do with python.