Skip to content

Instantly share code, notes, and snippets.

@elazar
Created April 7, 2012 03:12
Show Gist options
  • Save elazar/2324770 to your computer and use it in GitHub Desktop.
Save elazar/2324770 to your computer and use it in GitHub Desktop.
Python domain checker
#!/usr/bin/env python
import sys
import socket
import itertools
def filter_tlds(x): return x.startswith(".")
tlds = set(filter(filter_tlds, sys.argv[1:]))
non_tlds = set(sys.argv[1:]).difference(tlds)
for permutation in itertools.permutations(non_tlds):
domain = "".join(permutation)
for tld in tlds:
domain_tld = domain + tld
try:
socket.gethostbyname(domain_tld)
print(domain_tld + ": taken")
except:
print(domain_tld + ": available")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment