[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

How to read table's cell in ruby ?

Deepak kumar Shivhare

3/23/2007 12:36:00 PM

Hello,

Can anyone tell me how to read cells of a table on a webpage?
plz tell me methods.

Thanks in Advance
Deepak

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

2 Answers

Andreas S.

3/23/2007 12:44:00 PM

0

Deepak Kumar Shivhare wrote:
> Can anyone tell me how to read cells of a table on a webpage?
> plz tell me methods.

Take a look at Hpricot: http://code.whytheluckystiff.ne...

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

Peter Szinek

3/23/2007 1:01:00 PM

0

Deepak Kumar Shivhare wrote:
> Hello,
>
> Can anyone tell me how to read cells of a table on a webpage?
> plz tell me methods.

Check out scRUBYt!:

http://s...

Quick example:

Input
=================================================================
<html>
<body>
<table border=1 padding=10>
<tr>
<td>1</td>
<td>2</td>
</tr>
<tr>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
</table>
<br/>
<table border=1 padding=10>
<tr>
<td>6</td>
</tr>
<tr>
<td>7</td>
</tr>
<tr>
<td>8</td>
</tr>
</table>
<br>
<table border=1 padding=10>
<tr>
<td>9</td>
<td>10</td>
</tr>
<tr>
</tr>
<tr>
<td>11</td>
</tr>
</table>
</body>
</html>
=================================================================

scRUBYt program to extract all the cells:

=================================================================
table_data = Scrubyt::Extractor.define do

fetch "input.html"

cell '1'
end
=================================================================

output:

=================================================================
<root>
<cell>1</cell>
<cell>2</cell>
<cell>3</cell>
<cell>4</cell>
<cell>5</cell>
<cell>6</cell>
<cell>7</cell>
<cell>8</cell>
<cell>9</cell>
<cell>10</cell>
<cell>11</cell>
</root>
=================================================================

Cheers,
Peter
__
http://www.rubyra... :: Ruby and Web2.0 blog
http://s... :: Ruby web scraping framework
http://rubykitch... :: The indexed archive of all things Ruby