Deepak said:
Hello,
Can anyone tell me how to read cells of a table on a webpage?
plz tell me methods.
Check out scRUBYt!:
http://scrubyt.org
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.rubyrailways.com :: Ruby and Web2.0 blog
http://scrubyt.org :: Ruby web scraping framework
http://rubykitchensink.ca/ :: The indexed archive of all things Ruby