KnifeX

Ejemplo de API JSON

Sep 21st, 2020 (edited)
383
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.61 KB | None | 0 0
  1. import requests
  2. import json
  3. import os
  4. import socket
  5. from IPClass import IP
  6. from colors import red, green, blue, yellow
  7.  
  8. clear = lambda: os.system('cls')
  9.  
  10. APIKEY = 'RREYzPuI3bphUbEC13iifxf839k91'
  11. RepetirMenu = True
  12. repetirIPChecker = True
  13. while RepetirMenu:
  14.     clear()
  15.     print(blue('[1] VPN/PROXY/TOR Checker'))
  16.     print(blue('[2] Weather Checker'))
  17.     print(red('[0] Salir'))
  18.     print(' ')
  19.     opcion = input(yellow('Seleccione una opción por favor: '))
  20.  
  21.     if int(opcion) == 1:
  22.         while repetirIPChecker:
  23.             esCorrecto = False
  24.             while not esCorrecto:
  25.                 clear()
  26.                 ipaddress = input(yellow('Ingrese la dirección IP: '))
  27.                 ip = IP(ipaddress)
  28.                 if not ip.validate_ip(ipaddress):
  29.                     esCorrecto = True
  30.                 else:
  31.                     continue
  32.            
  33.             url = "https://www.ipqualityscore.com/api/json/ip/{}/{}".format(APIKEY,ipaddress)
  34.             args = { "strictness":0, "allow_public_access_points":"true", "fast":"true", "lighter_penalties":"true" }
  35.  
  36.             response = requests.get(url, params=args)
  37.  
  38.             if response.status_code == 200:
  39.                 """
  40.                file = open("response.html","wb")
  41.                file.write(content)
  42.                file.close()
  43.                """
  44.                 response_json = json.loads(response.text)
  45.                 ISP = response_json['ISP']
  46.                 VPN = response_json['vpn']
  47.                 PROXY = response_json['proxy']
  48.                 TOR = response_json['tor']
  49.                
  50.                 clear()
  51.                 print('ISP: ' + ISP)
  52.                 print(' ')
  53.                 print('VPN: ' + str(VPN))
  54.                 print('PROXY: ' + str(PROXY))
  55.                 print('TOR: ' + str(TOR))
  56.  
  57.                 print(' ')
  58.                 print('[Y] = Intentar Denuevo')
  59.                 print('[N] = Salir al menu principal')
  60.                 print('[X] = Salir del programa')
  61.                 print(' ')
  62.                 opcionCorrecta = False
  63.                 while not opcionCorrecta:
  64.                     validator = input('Elija su opción: ')
  65.  
  66.                     if validator == 'Y' or validator == 'y':
  67.                         break
  68.                     elif validator == 'N' or validator == 'n':
  69.                         repetirIPChecker = False
  70.                         break
  71.                     elif validator == 'X' or validator == 'x':
  72.                         exit()
  73.                     else:
  74.                         continue
  75.             else:
  76.                 print("Tu url no sirve")
Add Comment
Please, Sign In to add comment