I need to retrieve whois informations for a given site. because the whois content varies with each whois server, i need to parse the whois content what i'm getting.

I'm using php to show the content from db and initially tried in php to parse it. now i came to know there is ruby whois package which parses whois content.
so the idea is running ruby program in the background to put whois content in db then show using php if requests made.

I've installed ruby 1.8.7 and whois and tried examples given in ruby document. But its giving

/opt/lampp/htdocs/labs/ruby/ruby-whois.rb:1: uninitialized constant Whois (NameError)  

is rubywhois different from ruby? can anyone help me in this regard.

有帮助吗?

解决方案

Have you installed the library with gem install whois? After that you have to require it in your code (require 'whois') in order to be able to use it.

其他提示

I've found. These are things i've done.

  • Installed ruby, using yum install ruby
  • tried gem install whois, it asked me whether to install gem package and installed.
  • After installing rubygem, i used gem install whois command

Now i created a file with .rb extension with the following content,

require 'rubygems'
require 'whois'
r = Whois.whois("google.com")
puts r.created_on  

I run this file in terminal with this command,

ruby /opt/lampp/htdocs/labs/ruby/ruby-whois.rb

and the output is,

Mon Sep 15 00:00:00 +0530 1997  

Thanks for all your efforts.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top