Created
February 17, 2025 11:07
-
-
Save rxerium/5da0310115172dd86071249d9f0612dc to your computer and use it in GitHub Desktop.
This script performs bulk reverse WHOIS lookups for company names from an input file, queries the WhoisXML API to retrieve associated domain names, and saves the results in a structured JSON format.
This file contains hidden or 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
| import requests | |
| import json | |
| # API Key | |
| api_key = "<ENTER_API_KEY>" | |
| url = "https://reverse-whois.whoisxmlapi.com/api/v2" | |
| # Read input list (one company per line) | |
| with open("input.txt", "r", encoding="utf-8") as file: | |
| company_names = [line.strip() for line in file if line.strip()] | |
| # Open output file | |
| with open("output.json", "w", encoding="utf-8") as output_file: | |
| for company in company_names: | |
| print(f"Searching for: {company}") | |
| # Prepare payload | |
| payload = { | |
| "apiKey": api_key, | |
| "searchType": "current", | |
| "mode": "purchase", | |
| "basicSearchTerms": { | |
| "include": [company] | |
| } | |
| } | |
| try: | |
| response = requests.post(url, json=payload) | |
| data = response.json() | |
| # Structure output to include company name | |
| result = { | |
| "company_name": company, | |
| "domains_count": data.get("domainsCount", 0), | |
| "domains_list": data.get("domainsList", []) | |
| } | |
| # Write result to file (one JSON object per line) | |
| output_file.write(json.dumps(result) + "\n") | |
| print(f"Results saved for: {company}") | |
| except Exception as e: | |
| print(f"Error fetching data for {company}: {e}") | |
| print("Done! All results saved to output.json") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment