Skip to content

Instantly share code, notes, and snippets.

@mxbi
Created March 2, 2016 20:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mxbi/97cad7d95905c4d70590 to your computer and use it in GitHub Desktop.
Save mxbi/97cad7d95905c4d70590 to your computer and use it in GitHub Desktop.
Python script to look for available 3 letter domain names
import sys
import random
import string
import urllib.request as urllib2
import time
i = 1
while i < 2:
# Pick domain
tldlist = ["net","org"]
tld = random.choice(tldlist)
name = ''.join(random.choice(string.ascii_lowercase) for i in range(3))
domain = str(name) + "." + str(tld)
print("Attempting " + domain)
# Query API
apikey = "API KEY HERE"
url = "http://api.whoapi.com/?apikey=" + apikey + "&r=taken&domain=" + domain
s = urllib2.urlopen(url)
contents = str(s.read())
#print(contents)
# Parse XML
splitp = contents.split('"taken":')
splits = str(splitp[1]).split('}')
taken = splits[0]
# Write result to file
f = open('domains.txt', 'a')
result = domain + ' ' + str(taken)
print(result)
f.write(result)
f.close()
if taken == 0:
i = i + 1
print("Found free domain at:" + domain)
else:
time.sleep(62)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment