Merge pull request #1 from mfajer/master

Added command-line argument instead of user prompt.
This commit is contained in:
Nu2This 2018-03-23 11:45:09 -05:00 committed by GitHub
commit f1a4d29a8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,11 +1,12 @@
import argparse
import json import json
import requests import requests
import os import os
def search(): def search(host):
main_api = 'http://ip-api.com/json/' main_api = 'http://ip-api.com/json/'
ip = findMX() ip = findMX(host)
for host in ip: for host in ip:
json_data = requests.get(main_api + host).json() json_data = requests.get(main_api + host).json()
@ -17,8 +18,7 @@ def search():
json_data['query'], json_data['query'],
host)) host))
def findMX(): def findMX(host):
host = input("Who do you want to look up?: ")
p = os.popen('host -t MX ' + host) p = os.popen('host -t MX ' + host)
#initialize dicts #initialize dicts
@ -39,4 +39,10 @@ def findMX():
MXServer.append(split[6]) MXServer.append(split[6])
i = i + 1 i = i + 1
return MXServer return MXServer
search()
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("host", help="hostname to lookip")
args = parser.parse_args()
search(args.host)