Created
July 25, 2022 09:48
-
-
Save c3l3si4n/7fa2be3f899371ff138f55cb70c9c6d5 to your computer and use it in GitHub Desktop.
Quick script to fetch Reverse WhoIs data from WhoIsXMLAPI via CLI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
try: | |
import http.client as http | |
except ImportError: | |
import httplib as http | |
import json | |
import os | |
import sys | |
api_key = os.environ['WHOISXML_API_KEY'] | |
def print_response(txt): | |
return [print(x) for x in json.loads(txt)['domainsList']] | |
payload_basic = { | |
'basicSearchTerms': { | |
'include': [sys.argv[1]] | |
}, | |
'searchType': 'current', | |
'mode': 'purchase', | |
'apiKey': api_key, | |
'responseFormat': 'json' | |
} | |
headers = { | |
'Content-Type': 'application/json', | |
'Accept': 'application/json' | |
} | |
conn = http.HTTPSConnection('reverse-whois.whoisxmlapi.com') | |
conn.request('POST', '/api/v2', json.dumps(payload_basic), headers) | |
response = conn.getresponse() | |
text = response.read().decode('utf8') | |
print_response(text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment