Skip to content

Instantly share code, notes, and snippets.

@lysenkooo
Created November 19, 2015 09:41
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lysenkooo/62f263224ce7f71512bd to your computer and use it in GitHub Desktop.
Save lysenkooo/62f263224ce7f71512bd to your computer and use it in GitHub Desktop.
Domain Name Checker
#!/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