From: Ruby Ronin Date: 2007-12-01T08:47:37+09:00 Subject: Re: Need to parse a HTML table into an Array/hash ------=_Part_785_6611400.1196466460377 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline I'm kind of new too, so this might be a little sloppy by more experienced standards, but I think this gets you partially there. require "open-uri" conn = open("http://finance.yahoo.com/q/op?s=AAPL&m=2008-04").read table_data = conn.scan // table_data_refined = [] table_data.each { |data| data.gsub!(/<.+?>/, "") table_data_refined << data } You probably need to tweak the regexes to isolate the specific table you want (like plugging in "class=xxx"). I hope that helps. On Nov 30, 2007 1:24 PM, Ernst Tanaka wrote: > I am new to ruby; having a lot of fun, but currently I am stuck with the > following. > > I want to read this page > > http://finance.yahoo.com/q/op?s=AAPL&k=95.00&m=2007-12 > > Into an array or hash. > > I found the gem yahoo-finance; but that does not what I need. > I need to find the Symbol for (in this example) > AAPL call option strike 95 Dec-07. > > > > I am able to read the page: > conn = open("http://finance.yahoo.com/q/op?s=AAPL&m=2008-04") > lines = conn.read > > The main question is how to I parse the table which is in the middle of > the HTML. > > Any help is appreciated!! > -- > Posted via http://www.ruby-forum.com/. > > ------=_Part_785_6611400.1196466460377--