Created
August 14, 2017 16:00
-
-
Save joaumg/1e04ae325bacc9242497e656a722d36a to your computer and use it in GitHub Desktop.
Use the american dictionary to search for available domains.
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
#!/usr/bin/ruby | |
require 'whois' | |
require 'whois-parser' | |
require 'logger' | |
# | |
class WhoisDiscovery | |
def initialize | |
$stdout.sync = true | |
@logger = Logger.new($stdout) | |
File.open('/usr/share/dict/american-english', 'r').each_line do |word| | |
word = word.strip | |
next if word.include? "'" | |
whois("#{word}.com") | |
end | |
end | |
def whois(domain) | |
@logger.info "> whois(#{domain})" | |
parser = Whois::Client.new(timeout: 10).lookup(domain).parser | |
available = parser.available? | |
expires_on = parser.expires_on | |
@logger.info "< whois(#{domain}, #{available}, #{expires_on})" | |
rescue Timeout::Error, Whois::ConnectionError, Whois::ParserError | |
@logger.debug "whois.lookup(#{domain}) failed" | |
end | |
end | |
WhoisDiscovery.new |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment