Skip to content

Instantly share code, notes, and snippets.

@liruqi
Created December 18, 2017 12:52
Show Gist options
  • Save liruqi/ed07b1f7cbee981f7bae511e91b571c8 to your computer and use it in GitHub Desktop.
Save liruqi/ed07b1f7cbee981f7bae511e91b571c8 to your computer and use it in GitHub Desktop.
Check expired domains
import socket
import pprint
import sys
import os
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('--input', default='')
parser.add_argument('--output', default='output.txt')
args = parser.parse_args()
domains = []
if len(args.input) > 0:
df = open(args.input, 'r')
domains = df.read().split('\n')
else:
domains = sys.argv[1:]
cnt = 0
badnames = {}
goodnames = []
for k in domains:
cnt += 1
print (k, cnt, '/', len(domains))
activePath = 'active/' + k
expiredPath = 'expired/' + k
try:
if os.path.exists(activePath):
print (k, activePath)
goodnames.append(k)
elif os.path.exists(expiredPath):
print (k, expiredPath)
continue
else:
info = socket.gethostbyname_ex(k)
print k, info
wf = open(activePath, 'w')
wf.write(str(info))
wf.close()
except Exception as e:
print k, e
wf = open(expiredPath, 'w')
wf.write(str(e))
wf.close()
badnames[k] = 1
print "\n".join(goodnames)
wf = open(args.output, 'w')
wf.write( "\n".join(goodnames) )
wf.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment