Created
June 29, 2012 17:04
-
-
Save williamcotton/3019239 to your computer and use it in GitHub Desktop.
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
require 'colored' | |
class RegExAvailableDomains | |
def initialize(regex, show_output) | |
@regex = regex | |
@show_output = show_output | |
@matching_words = [] | |
@available_domains = [] | |
find | |
end | |
def find | |
File.open("/usr/share/dict/words") do |file| | |
file.each do |line| | |
begin | |
word = line.strip | |
if word.match(@regex) | |
@matching_words << word | |
dot_com = word[1..-1] + ".com" | |
whois = `whois #{dot_com}` | |
if whois.split("\n")[7].include?("No match for") | |
@available_domains << dot_com | |
puts dot_com.green if @show_output | |
else | |
puts dot_com.red if @show_output | |
end | |
end | |
rescue | |
puts "error with: " + word if @show_output | |
end | |
end | |
end | |
@available_domains | |
end | |
end | |
RegExAvailableDomains.new(/^.ele.*/, true) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment