Created
March 2, 2016 20:55
-
-
Save mxbi/97cad7d95905c4d70590 to your computer and use it in GitHub Desktop.
Python script to look for available 3 letter domain names
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
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