Created
May 10, 2013 09:23
-
-
Save russellbeattie/5553420 to your computer and use it in GitHub Desktop.
Cranks up the number of simultaneous requests, but nic.io just barfs at you after a short while.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# works on my machine... OS X 10.8.2, Python v2.7.3 | |
import sys | |
import subprocess | |
import multiprocessing | |
def checkName(q): | |
proc_name = multiprocessing.current_process().name | |
print 'Starting process', proc_name | |
while True: | |
domain = q.get() | |
try: | |
out = subprocess.check_output(['whois', domain]) | |
if 'Not' not in out: | |
print domain | |
except Exception as e: | |
print "Other Exception", e | |
except KeyboardInterrupt: | |
return | |
if __name__ == '__main__': | |
print 'Starting' | |
wordlist = 'words.txt' | |
if len(sys.argv) > 1: | |
wordlist = sys.argv[1] | |
procs = 10 | |
queue = multiprocessing.Queue(procs) | |
p = multiprocessing.Pool(procs, initializer=checkName, initargs=(queue,)) | |
try: | |
for line in open(wordlist, 'r'): | |
domain = line.strip() + '.io' | |
queue.put(domain) | |
except KeyboardInterrupt: | |
sys.exit() | |
finally: | |
p.terminate() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment