-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathclean_sites.py
25 lines (23 loc) · 892 Bytes
/
clean_sites.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
import dns.resolver
import sys
resolver = dns.resolver.Resolver()
with open(sys.argv[1]) as f:
for url in f:
try:
url = url.strip('\n').split('/')[0]
answer = resolver.query(url, 'A')
with open('existing_domains.txt', 'a') as r:
r.write(url + '\n')
print url
except dns.resolver.NXDOMAIN:
with open('nonexisting_domains.txt', 'a') as r:
r.write('{0}\n'.format(url + ' NX'))
print url + ' NX'
except dns.resolver.NoAnswer:
with open('nonexisting_domains.txt', 'a') as r:
r.write('{0}\n'.format(url + ' NoAnswer'))
print url + ' NoAnswer'
except:
with open('nonexisting_domains.txt', 'a') as r:
r.write('{0}\n'.format(url + ' No NS'))
print url + ' No NS'