Created
November 12, 2011 04:13
-
-
Save rawsyntax/1360029 to your computer and use it in GitHub Desktop.
ruby domain name generator
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
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'whois' | |
module Domaing | |
def self.alliterative?(first_word, second_word) | |
first_word[0] == second_word[0] | |
end | |
def self.generate_names(words) | |
first = words[rand(words.size)].strip.downcase | |
second = words[rand(words.size)].strip.downcase | |
"#{first}#{second}.com" if alliterative?(first, second) | |
end | |
def self.generate_domains | |
words = [] | |
# get the 2of12 dictionary here: | |
# http://scrapmaker.com/data/wordlists/twelve-dicts/2of12.txt | |
File.open("2of12.txt", "r").each_line do |l| | |
words << l if l.length > 4 && l.length < 7 | |
end | |
domains = [] | |
while domains.count < 30000 | |
domain = generate_names(words) | |
domains << domain if domain | |
end | |
domains.each do |d| | |
sleep 5 | |
begin | |
if Whois.whois(d).available? | |
File.open("domains.txt", "a") do |f| | |
f.write "#{d}\n" | |
end | |
end | |
rescue | |
sleep 100 # to avoid overloading whois servers | |
end | |
end | |
end | |
end | |
Domaing.generate_domains |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment