> #!/usr/bin/ruby -w
> 
> data = File.read(sourcefilename)
> 
> output = []
> 
> html_rows = data.scan(%r{<tr.*?>(.*?)</tr>}im).flatten
> 
> html_rows.each do |row|
>    # filter these undesired elements
>    row.gsub!("&nbsp;","")
>    row.gsub("</a>","")
>    cells = row.scan(%r{<td.*?>(.*?)</td>}im).flatten
>    output << cells
> end
> 
> # done collecting, now display
> 
> output.each do |row|
>    line = row.join(",")
>    puts line
> end
> 

What will be right solution if some one wants to get the data from yahoo 
site http://finance.yahoo.com/q?s=IBM and then displaying only some 
values such as Prev Close, Last Trade. Lets suppose we go to the URL 
through :

require 'watir'
include Watir
require 'hpricot'
include Hpricot
ie=Watir::IE.new
ie.goto("http://finance.yahoo.com/q?s=IBM")

Now, whats next. Also let suppose we want to get all the values of 
table, we don't know the table structure then what what should be the 
correct solution ?

-- 
Posted via http://www.ruby-forum.com/.