#!/usr/bin/env ruby # # Retrieves whois data # # Author: Chris Blackburn(cblackburn@cbciweb.com) # Copyright: (c) 2006 Chris Blackburn # License: GPL: http://www.gnu.org/copyleft/gpl.html # Date: January 3, 2007 # $Revision:$ # require 'hpricot' require '../lib/hpricot_helper' require 'net/http' require 'uri' def usage puts "usage: smartwhois.rb " exit end def post(baseurl, options) res = Net::HTTP.post_form( URI.parse(baseurl), options ) end # Parse the commandline args ip = ARGV.shift if ip result = post('http://www.all-nettools.com/toolbox', {'smartwhois' => "#{ip}", 'swsubmit' => 'GO%21'} ) body = result.body.gsub(/\\r\\n/, "\r\n") else usage end puts "------------------------------------------------------------" puts "#{ip}" puts "------------------------------------------------------------" doc = Hpricot(body) (doc/:img).strip table = (doc/"#resultTable") table.search("td") do |cell| line = cell.inner_html line.gsub!(/|<\/b>|^
$/, '') line.gsub!(/
/, "\n") #p line unless line.empty? puts line unless line.empty? end puts "============================================================"