-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbulk_whois.py
43 lines (38 loc) · 1.25 KB
/
bulk_whois.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/python3
import pythonwhois
import csv
import time
with open('bulk_whois_results.csv', 'w+', newline="") as outfile:
w = csv.writer(outfile)
w.writerow(['Domain Name', 'Registrar', 'Expiration Date', 'Nameservers'])
# outfile.close()
result_list = []
with open('domain_list', 'r') as f:
for domain in f.readlines():
# whois_csv(domain.strip())
whois_data = pythonwhois.get_whois(domain.strip())
try:
eDate = ' '.join(str(x) for x in whois_data['expiration_date'])
result_dict = {
'domain': domain.strip(),
'registrar': whois_data['registrar'],
'edate': eDate,
'nameservers': whois_data['nameservers']
}
result_list.append(result_dict)
time.sleep(15)
except Exception as e:
# pass
print(e, domain.strip())
for dom in result_list:
print(dom)
with open('bulk_whois_results.csv', 'a+', newline="") as outfile:
w = csv.writer(outfile)
for i in result_list: # eg list or dictionary i'm assuming a list structure
w.writerow([
i['domain'],
i['registrar'],
i['edate'],
i['nameservers'],
])
print('done')