Created
November 19, 2015 09:41
-
-
Save d1ys3nk0/62f263224ce7f71512bd to your computer and use it in GitHub Desktop.
Domain Name Checker
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/env ruby | |
require 'socket' | |
require 'whois' | |
zones = %w(com ru) | |
words = %w( | |
word1 | |
word2 | |
word3 | |
word4 | |
word5 | |
).uniq.sort | |
available_num = unavailable_num = 0 | |
zones.each do |zone| | |
words.each do |first_word| | |
words.each do |second_word| | |
domain = "#{first_word}#{second_word}.#{zone}" | |
begin | |
Socket.gethostbyname(domain) | |
unavailable_num += 1 | |
rescue SocketError | |
begin | |
r = Whois.whois(domain) | |
if r.available? | |
available_num += 1 | |
puts domain | |
end | |
rescue | |
puts domain | |
end | |
end | |
end | |
end | |
end | |
puts "Total: #{available_num + unavailable_num}" | |
puts "Available: #{available_num}" | |
puts "Unavailable: #{unavailable_num}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment