app.py
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
import whois import csv domain = "facebook.com" w = whois.whois(domain) print(w) whois_data = dict(w) csv_filename = f"{domain.replace('.', '_')}_whois.csv" with open(csv_filename, mode='w', newline='', encoding='utf-8') as csvfile: writer = csv.writer(csvfile) writer.writerow(['Field', 'Value']) # Header row for key, value in whois_data.items(): # Convert list values to comma-separated strings if isinstance(value, list): value = ', '.join(map(str, value)) writer.writerow([key, value]) print(f"WHOIS data saved to '{csv_filename}'") |