Skip to content

Instantly share code, notes, and snippets.

@angeloped
Created November 22, 2019 10:55
Show Gist options
  • Save angeloped/127395a702e66c563f70e992957218e3 to your computer and use it in GitHub Desktop.
Save angeloped/127395a702e66c563f70e992957218e3 to your computer and use it in GitHub Desktop.
IP Tracking System with ip-api. Compatible in Python 2.x and 3.x. Try it!
import json
import requests
import webbrowser
def _input(form):
try:
return raw_input(form)
except:
return input(form)
tracing = _input("Enter IP (default if none): ")
# get JSON result
req = requests.get("http://ip-api.com/json/{0}".format(tracing)).json()
if req["status"] == "success":
result = """
IP: {0}
Address: {1}, {2} ({3})
Region: {4}
Zip: {5}
T-zone: {6}
Coords:
LAT: {7}
LON: {8}
ISP: {9}
Org: {10}
"""
result = result.format(req["query"], req["city"], req["country"], req["countryCode"], req["region"], req["zip"], req["timezone"], req["lat"], req["lon"], req["isp"], req["org"])
print(result)
mapping = """[1] Google Map
[2] Ip Tracker
Which web service you'd like
to geolocate IP (select none to exit): """
choice = _input(mapping)
if choice == "1":
webbrowser.open("https://www.google.com/maps/@{0},{1},13z".format(req["lat"], req["lon"]))
elif choice == "2":
webbrowser.open("https://www.ip-tracker.org/locator/ip-lookup.php?ip={0}".format(req["query"]))
else:
print("We FAILED attempting to track subject..")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment