def get_info_by_ip(ip='82.202.165.96'):
try:
response = requests.get(url=f'http://ip-api.com/json/{ip}').json()
data = {
'IP': response.get('query'),
'Country': response.get('country'),
'City': response.get('city'),
'ISP': response.get('isp')
}
for k, v in data.items():
print(f'{k}: {v}')
except requests.exceptions.ConnectionError:
print('[!] Please check your internet connection')
import requests
def get_info_by_ip(ip):
try:
response = requests.get(f'http://ip-api.com/json/{ip}').json()
print(response)
except requests.exceptions.ConnectionError:
print('[!] Пожалуйста, проверьте подключение к интернету')
except requests.exceptions.RequestException as e:
print(f'[!] Произошла ошибка: {e}')
def main():
ip = input('Пожалуйста, введите целевой IP: ')
get_info_by_ip(ip)
if __name__ == '__main__':
main()
теперь всё работает {"status":"success","country":"Russia","countryCode":"RU","region":"IRK","regionName":"Irkutsk Oblast","city":"Irkutsk","zip":"","lat":52.2281,"lon":104.282,"timezone":"Asia/Irkutsk","isp":"SERVER","org":"Server JSC","as":"AS29182 JSC IOT","query":"82.202.165.96"}