Using hpricot to get tables

L

lrlebron

I am working with the following script to parse a page

require 'hpricot'
require 'open-uri'

strLink ="http://www.sportsline.com/mlb/gamecenter/boxscore/
MLB_20080331_ARI@CIN"
strPath ="div[@class=SLTables1]/div"

@Doc = Hpricot(open(strLink))

@doc.search(strPath) do |div|
puts div.inner_html
# puts div.css_path
# puts div.xpath
# puts
puts
end


This prints 4 tables to the screen

<table> blah, blah, blah </table>

<table> blah, blah, blah </table>

<table> blah, blah, blah </table>

<table> blah, blah, blah </table>


I would like to access each table individually. How can I do that?

Thanks,

Luis
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,780
Messages
2,569,608
Members
45,244
Latest member
cryptotaxsoftware12

Latest Threads

Top