Skip to content

Instantly share code, notes, and snippets.

@aquabu
Last active August 29, 2015 13:57
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 aquabu/9680034 to your computer and use it in GitHub Desktop.
Save aquabu/9680034 to your computer and use it in GitHub Desktop.
# so you have a list of domain names you want to search for in a text file
# maybe you generated them with my pattern_matcher gem: https://github.com/aquabu/pattern_expander
# here's a cheap and dirty way to see if they are available
require 'whois' # this is the ruby-whois gem
def lookup(name)
domain = name.chomp + '.com'
w = Whois.whois(domain)
STDOUT.syswrite(domain + "\n") if w.available?
rescue Timeout::Error, Errno::ECONNRESET, Whois::ConnectionError
retry
end
File.open('cvcvc.txt') do |file_handle|
file_handle.each_line do |name|
lookup(name)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment