Code :
import os
import urllib.request as urllib2
import json
# Use a while loop to continuously prompt the user for the target IP address
while True:
# Prompt the user to input the target IP address
ip = input("What is your target IP: ")
# Construct the URL for the ip-api.com JSON API
url = "http://ip-api.com/json/"
# Send a request to the ip-api.com API to retrieve the geolocation information
response = urllib2.urlopen(url + ip)
# Read the response data
data = response.read()
# Parse the JSON response data into a Python dictionary
values = json.loads(data)
# Print the geolocation information for the target IP address
print("IP: " + values["query"])
print("City: " + values["city"])
print("ISP: " + values["isp"])
print("Country: " + values["country"])
print("Region: " + values["region"])
print("Timezone: " + values["timezone"])
# Exit the loop after printing the information once
break
#clcoding.com
0 Comments:
Post a Comment