-
-
Save benjaminSchilling33/5161e87129c419d9ceb28f693b9f8e81 to your computer and use it in GitHub Desktop.
Combine pairs of words from a set and check if the resulting URL is available.
This file contains hidden or 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 requests | |
# hard-limited timeout (https://stackoverflow.com/a/22096841) | |
import eventlet | |
eventlet.monkey_patch() | |
words = ["met", "metrology", "meas", "measurement", "sensor", "cal", "calibration", | |
"instrument", "test", "aid", "source", "cyc", "titan", "titanium", "tensor", | |
"creative", "virtual", "vision", "visionary", "kick", "elegant", "current", | |
"res", "resolution", "micro", "ultimate", "prime", "exponential", "scientific", | |
"principle", "export", "myriad", "idea", "solution", "enterprise", "appliance", | |
"service", "device", "group", "product", "international", "reliable", "preci", | |
"precise", "corp", "corporation", "robust", "clock", "lab", "laboratory", | |
"quantum", "dream", "physics", "amp", "amplified", "electronics", "chain", "plasma", | |
"inno", "innovation", "system", "industry", "circuit", "intelligence", "tera", | |
"yotta"] | |
tlds = ["com", "org", "de", "net"] | |
allComb = len(words)**2 - len(words) # skip diagonal | |
output_filename = "company_names.txt" | |
with open(output_filename, "w") as f: | |
f.write("") | |
i=0 | |
for word in words: | |
wordCaml = word[0].upper() + word[1:] | |
for word2 in words: | |
word2Caml = word2[0].upper() + word2[1:] | |
if word != word2: | |
urlAvail = True | |
for tld in tlds: | |
url = "www."+word+word2+"."+tld | |
stat = -1 | |
try: | |
with eventlet.Timeout(1): | |
stat = requests.head("http://" + url, timeout=1, verify=False).status_code | |
except: | |
pass | |
print("stat=%d for url=%s"%(stat, url)) | |
if stat//100 == 2 or stat//100 == 3: # 2xx: success ; 3xx: redirection | |
urlAvail = False | |
break | |
if urlAvail: | |
with open(output_filename, "a") as f: | |
f.write(str(i)+" "+wordCaml+word2Caml+"\n") | |
print("%d / %d: %100s available :-)"%(i, allComb, wordCaml+word2Caml)) | |
else: | |
print("%d / %d: %100s taken :-("%(i, allComb, wordCaml+word2Caml)) | |
i+=1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment