Skip to content

Instantly share code, notes, and snippets.

@c3l3si4n
Created July 25, 2022 09:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save c3l3si4n/7fa2be3f899371ff138f55cb70c9c6d5 to your computer and use it in GitHub Desktop.
Save c3l3si4n/7fa2be3f899371ff138f55cb70c9c6d5 to your computer and use it in GitHub Desktop.
Quick script to fetch Reverse WhoIs data from WhoIsXMLAPI via CLI
#!/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