Forum: Ruby can we read webpage grid data into an excel?

Posted by Love U Ruby (my-ruby)
on 2013-01-11 22:13
Hi,

I am using one third party web application, where in one pag all the
data is presented in grid format.

But i am not able to understand how should i read such grid html table
stored values?

Any help in this regard?
Posted by Joel Pearson (virtuoso)
on 2013-01-12 01:36
I recommend handing the table's HTML to Nokogiri and letting it do the 
parsing for you.

For example (using "driver" as Firefox with watir-webdriver):

require 'nokogiri'
doc = Nokogiri::HTML(driver.table(:id => 'example').html)

doc.css('tr').each do |row|
  row.css('td').each do |cell|
    puts cell.text
  end #Cell loop
end #Row loop
Posted by "Jesús Gabriel y Galán" <jgabrielygalan@gmail.com> (Guest)
on 2013-01-13 11:38
(Received via mailing list)
On Fri, Jan 11, 2013 at 10:13 PM, Arup Rakshit <lists@ruby-forum.com> 
wrote:
> Hi,
>
> I am using one third party web application, where in one pag all the
> data is presented in grid format.
>
> But i am not able to understand how should i read such grid html table
> stored values?
>
> Any help in this regard?

The easiest way is to use an HTML parser such as Nokogiri, and then
use xpath to get at the values.

Jesus.
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.