From: Vikash Kumar Date: 2006-11-28T19:03:29+09:00 Subject: Re: How to get data from html table > #!/usr/bin/ruby -w > > data = File.read(sourcefilename) > > output = [] > > html_rows = data.scan(%r{(.*?)}im).flatten > > html_rows.each do |row| > # filter these undesired elements > row.gsub!(" ","") > row.gsub("","") > cells = row.scan(%r{(.*?)}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/.