Fsoky

Получение информации об IP | Fsoky

Aug 6th, 2020
1,072
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.04 KB | None | 0 0
  1. import requests
  2.  
  3. global get_ip
  4. get_ip = input( '[+] IP : ' )
  5.  
  6. def info():
  7.     response = requests.get( f'http://ipinfo.io/{ get_ip }/json' )
  8.  
  9.     user_ip = response.json()[ 'ip' ]
  10.     user_city = response.json()[ 'city' ]
  11.     user_region = response.json()[ 'region' ]
  12.     user_country = response.json()[ 'country' ]
  13.     user_location = response.json()[ 'loc' ]
  14.     user_org = response.json()[ 'org' ]
  15.     user_timezone = response.json()[ 'timezone' ]
  16.  
  17.     global all_info
  18.     all_info = f'\n<INFO>\nIP : { user_ip }\nCity : { user_city }\nRegion : { user_region }\nCountry : { user_country }\nLocation : { user_location }\nOrganization : { user_org }\nTime zone : { user_timezone }'
  19.  
  20.     print( all_info )
  21.  
  22. def record():
  23.     user_record = input( '\n[?] Record (y/n): ' )
  24.  
  25.     if user_record == 'y':
  26.         file = open( 'data_ip.txt', 'a' )
  27.         file.write( f'{ all_info }\n' )
  28.         file.close()
  29.  
  30.         print( '\nSuccess!' )
  31.  
  32.     if user_record == 'n':
  33.         print( '\n<O.K>' )
  34.  
  35. def main():
  36.     info()
  37.     record()
  38.  
  39. main()
Add Comment
Please, Sign In to add comment