开发者

Using ruby whois

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜