This script allows you to:
Prerequisites:
import requests
import socket
import os
def my_info_ip():
try:
response = requests.get(f"https://ipinfo.io/")
if response.status_code == 200:
data = response.json()
for key, value in data.items():
print(f"{key}: {value}")
else:
print("La requête à l'API a échoué.",response)
except Exception as e:
print(f"Une erreur s'est produite : {str(e)}")
def get_ip_info(ip_address):
try:
os.system('cls')
response = requests.get(f"https://ipinfo.io/{ip_address}/json")
if response.status_code == 200:
data = response.json()
for key, value in data.items():
print(f"{key}: {value}")
else:
print("La requête à l'API a échoué.")
except Exception as e:
print(f"Une erreur s'est produite : {str(e)}")
os.system('cls')
print("--- MY INFOS ---")
my_info_ip()
print("----------------")
ip_address = input("Entrez une adresse IP : ")
get_ip_info(ip_address)
- Display information about your IP address.
- Enter an IP address and obtain its information, for example:
- IP: YOUR IP
- City: Winston-Salem
- Region: North Carolina
- Country: US
- Location: 36.0999, -80.2442
- Organization: AS81 MCNC
- Postal Code: 27111
- Timezone: America/New_York
Prerequisites:
- requests: pip install requests
import requests
import socket
import os
def my_info_ip():
try:
response = requests.get(f"https://ipinfo.io/")
if response.status_code == 200:
data = response.json()
for key, value in data.items():
print(f"{key}: {value}")
else:
print("La requête à l'API a échoué.",response)
except Exception as e:
print(f"Une erreur s'est produite : {str(e)}")
def get_ip_info(ip_address):
try:
os.system('cls')
response = requests.get(f"https://ipinfo.io/{ip_address}/json")
if response.status_code == 200:
data = response.json()
for key, value in data.items():
print(f"{key}: {value}")
else:
print("La requête à l'API a échoué.")
except Exception as e:
print(f"Une erreur s'est produite : {str(e)}")
os.system('cls')
print("--- MY INFOS ---")
my_info_ip()
print("----------------")
ip_address = input("Entrez une adresse IP : ")
get_ip_info(ip_address)