|
@ -2,14 +2,21 @@ import argparse |
|
|
import requests |
|
|
import requests |
|
|
import os |
|
|
import os |
|
|
import re |
|
|
import re |
|
|
|
|
|
import sys |
|
|
|
|
|
import traceback |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def query_api(host): |
|
|
def query_api(host): |
|
|
main_api = 'http://ip-api.com/json/' |
|
|
main_api = 'http://ip-api.com/json/' |
|
|
# For every host do an API request |
|
|
# For every host do an API request |
|
|
|
|
|
try: |
|
|
for x in host: |
|
|
for x in host: |
|
|
json_data = requests.get(main_api + x).json() |
|
|
json_data = requests.get(main_api + x).json() |
|
|
|
|
|
if 'message' in json_data: |
|
|
|
|
|
print('\nThe IP "{}" is {}'.format(x, |
|
|
|
|
|
json_data['message'])) |
|
|
# Print out wanted JSON data formatted nicely |
|
|
# Print out wanted JSON data formatted nicely |
|
|
|
|
|
else: |
|
|
print('\nCity\State: {}, {}\n' |
|
|
print('\nCity\State: {}, {}\n' |
|
|
'Country: {}\n' |
|
|
'Country: {}\n' |
|
|
'ISP: {}\n' |
|
|
'ISP: {}\n' |
|
@ -21,6 +28,11 @@ def query_api(host): |
|
|
json_data['isp'], |
|
|
json_data['isp'], |
|
|
json_data['query'], |
|
|
json_data['query'], |
|
|
x)) |
|
|
x)) |
|
|
|
|
|
except KeyError: |
|
|
|
|
|
traceback.print_exc(file=sys.stdout) |
|
|
|
|
|
print('Key Error') |
|
|
|
|
|
print('JSON: ') |
|
|
|
|
|
print(json_data) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def findMX(host): |
|
|
def findMX(host): |
|
|