Skip to content

Instantly share code, notes, and snippets.

@rxerium
Created February 17, 2025 11:09
Show Gist options
  • Select an option

  • Save rxerium/f108c995cb532df232eace1ffd2e30e8 to your computer and use it in GitHub Desktop.

Select an option

Save rxerium/f108c995cb532df232eace1ffd2e30e8 to your computer and use it in GitHub Desktop.
This script performs bulk reverse WHOIS lookups using the Whoxy API to retrieve domain registration details for a list of organizations, saving the results to a JSONL file while respecting API rate limits.
import requests
import time
def read_org_names(file_path):
"""Read organization names from a file (one per line)."""
with open(file_path, 'r', encoding='utf-8') as file:
return [line.strip() for line in file if line.strip()]
def query_whoxy(api_key, org_name):
"""Query the Whoxy API for reverse WHOIS lookup based on organization name."""
url = f"https://api.whoxy.com/?key={api_key}&reverse=whois&company={org_name}"
response = requests.get(url)
if response.status_code == 200:
return response.json()
else:
print(f"Error {response.status_code} for {org_name}: {response.text}")
return None
def main():
api_key = "APIKEY" # Replace with your actual API key
input_file = "orgnames.txt" # The file containing organization names
output_file = "whoxy_results-test.jsonl" # Output file to store results
org_names = read_org_names(input_file)
with open(output_file, 'a', encoding='utf-8') as out_file:
for org_name in org_names:
print(f"Querying WHOIS for: {org_name}")
result = query_whoxy(api_key, org_name)
if result:
out_file.write(f"{result}\n")
print("Waiting 30 seconds to respect rate limits...")
time.sleep(30)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment