-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathdomaindownload.py
More file actions
28 lines (23 loc) · 836 Bytes
/
domaindownload.py
File metadata and controls
28 lines (23 loc) · 836 Bytes
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
#!/usr/bin/env python3
import base64
import os
import re
import requests
from datetime import datetime, timedelta
from io import BytesIO
from zipfile import ZipFile
if 'keyword' not in os.environ:
exit('ERROR: Missing \'keyword\' Environment Variable')
keywords = re.split(r'[^a-z0-9-]', os.environ['keyword'])
for i in range(4):
f = (datetime.now() - timedelta(days=i)).strftime('%Y-%m-%d') + '.zip'
try:
r = requests.get(f'https://www.whoisds.com/whois-database/newly-registered-domains/{base64.b64encode(f.encode()).decode()}/nrd')
z = ZipFile(BytesIO(r.content))
for l in z.open('domain-names.txt').readlines():
if not re.search('({})'.format('|'.join(keywords)), l.decode()):
continue
print(l.decode().strip())
break
except:
pass