Check domain availability in Ruby
The whois gem allows you to query whois information for a domain.
Install the gem via RubyGems
$ gem install whois
Use the following Ruby code to check if a domain is available.
Whois.available?(domain)
Here's an example.
def availability(domain)
if Whois.available?(domain)
puts "The domain #{domain} is available"
else
"The domain #{domain} is not available"
end
end
puts availability("example.com")
# => The domain example.com is not available
puts availability("efdsvgerwfacdsvfbgrwefadsc.com")
# => The domain efdsvgerwfacdsvfbgrwefadsc.com is not available
Written by Simone Carletti
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#