943,310 Members | Top Members by Rank

Ad:
  • Ruby Code Snippet
  • Views: 1945
  • Ruby RSS
0

Domain Name Checker

by on Aug 1st, 2009
A simple domain name checker. This script use service from who.is
Usage:
ruby domainchecker.rb <domain_name>
Ruby Code Snippet (Toggle Plain Text)
  1. #!/usr/bin/ruby
  2. #
  3. # This script is available under the GPLv3 License.
  4. # USE COMPLETELY ON YOUR OWN RISK.
  5. # written by slac3dork & tested on Linux
  6. # http://snippet.c0de.me
  7.  
  8. require 'open-uri'
  9.  
  10. if ARGV.size < 1
  11. puts '[-] Usage ./domainchecker.rb <domain_name>'
  12. exit 1
  13. end
  14.  
  15. puts '-----------------------------------------------'
  16. puts '[+] Domain Checker tool'
  17. puts '[+] domainchecker.rb'
  18. puts '[+] Coded by slac3dork'
  19. puts "-----------------------------------------------\n\n"
  20.  
  21. begin
  22. domain_name = ARGV[0]
  23. open("http://www.who.is/whois/#{domain_name}") {|page|
  24. page.each_line {|line|
  25. if (line =~ /Invalid Domain or IP/)
  26. puts '[-] ERROR! Please check your domain name'
  27. exit 1
  28. end
  29.  
  30. if (line =~ /Registry Whois Information/)
  31. puts "[-] #{domain_name} is not available"
  32. end
  33.  
  34. if (line =~ /Available for Registration/)
  35. puts "[+] #{line.slice(/([a-z]+[\.]{1}[a-z]{2,})( is Available for Registration)/)}"
  36. end
  37.  
  38. if (line =~ /./)
  39. avail_domain = line.slice(/domain=[a-z]+[\.]{1}[a-z]{2,}/).slice(/[a-z]+[\.]{1}[a-z]{2,}/)
  40. puts "[+] Available Domain: #{avail_domain}"
  41. end
  42. }
  43. }
  44. rescue
  45. puts '[-] Error while executing Domain Checker script. Check you internet connection'
  46. end
Message:
Previous Thread in Ruby Forum Timeline: Names starting with ":"
Next Thread in Ruby Forum Timeline: Artificial System Clock Code review critique





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC