Last active
August 29, 2015 13:57
-
-
Save aquabu/9680034 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
# 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