-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
50 lines (36 loc) · 1.84 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import requests
import pystyle
from pystyle import Colors, Colorate
API_KEY = 'YOUR_API_KEY_HERE'
def localiser_ip(ip):
url = f'http://api.ipstack.com/{ip}?access_key={API_KEY}'
response = requests.get(url)
if response.status_code == 200:
data = response.json()
pays = data['country_name']
region = data['region_name']
ville = data['city']
code_postal = data['zip']
latitude = data['latitude']
longitude = data['longitude']
type = data['type']
print(Colorate.Horizontal(Colors.blue_to_cyan,f' Country : {pays}'))
print(Colorate.Horizontal(Colors.blue_to_cyan,f' Region : {region}'))
print(Colorate.Horizontal(Colors.blue_to_cyan,f' City : {ville}'))
print(Colorate.Horizontal(Colors.blue_to_cyan,f' Postcode : {code_postal}'))
print(Colorate.Horizontal(Colors.blue_to_cyan,f' Latitude : {latitude}'))
print(Colorate.Horizontal(Colors.blue_to_cyan,f' Longitude : {longitude}'))
print(Colorate.Horizontal(Colors.blue_to_cyan,f' Type : {type}'))
else:
print(Colorate.Horizontal(Colors.red_to_yellow,'An error occurred during the API request...'))
adresse_ip = input(Colorate.Horizontal(Colors.blue_to_cyan,"""
___ ____ ___ _ _ _____ ___ ____
|_ _| | _ \ |_ _| | \ | | | ___| / _ \ / ___|
| | | |_) | | | | \| | | |_ | | | | \___ \
| | | __/ | | | |\ | | _| | |_| | ___) |
|___| |_| |___| |_| \_| |_| \___/ |____/
BY NYXOY
Enter IP address :"""))
localiser_ip(adresse_ip)
leave = input(Colorate.Horizontal(Colors.blue_to_cyan,"""
Press any key to exit """))