Intuduction When we need to check some IP address information , do we have to open the browser, then type the googl domain and copy-paste the IP address? In this article . I'm goinG to use python with IP GUIDE to check ipaddres information .This much better before. Let's started Install Python found what version can be match your OS , download it and installl .https://www.python.org/downloads/ Install requests library website: https://pypi.org/project/requests/ $ python -m pip install requests Code #import requests library import requests #get data from ip guide response = requests.get(f'https://ip.guide/').json() #function get_ip def get_ip(): return response["ip"] #function get_location def get_location(): location_data = { "Latitude":response["location"]["latitude"], "Longitude" : response["location"]["longitude"], "City": response["location"]["city"], "Country": response["location"]["country"] } return location_data #function get_network def get_network(): network_data = { "Cidr": response["network"]["cidr"], "Host Start" : response["network"]["hosts"]["start"], "Host end" : response["network"]["hosts"]["end"] } return network_data #dictionary variable network_data = get_network() location_data = get_location() ipaddress = get_ip() 1. output information print(f"Your internet IPaddress is :{ipaddress}\n and below is this IPaddress other informations\n") 1. for loop for key,value in network_data.items(): print(f"{key}: {value}") print(" \n") for key,value in location_data.items(): print(f"{key}: {value}") print(" \n") Refrence: https://ip.guide/ https://pypi.org/project/requests/

December 2, 2023 0comments 37hotness 0likes Read all