Re: HTML Parsing issues - Part II



On May 25, 5:15 am, Gunnar Hjalmarsson <nore...@xxxxxxxxx> wrote:
cha...@xxxxxxxxxxxxxxxx wrote:
I'm trying to have the following script parse

<table class="item_description">
<tr>
<td>Acer Aspire AS5610-2089 Notebook, Intel Pentium Dual Core
T2080, 1.6 GHz, 1024GB, 160GB, DVD+/-R DL/DVD+RW Drive, 15.4" TFT,
WebCam, 56K Modem, Wireless, NIC, Vista Home Premium, Refurbished with
90 Day Warranty</td>
</tr>
</table>

From the following url

http://www.doba.com/catalog/2988526.html

use LWP::Simple;
use HTML::TokeParser;

my $html = get 'http://www.doba.com/catalog/2988526.html';
my $p = HTML::TokeParser->new( \$html );

while ( my $table = $p->get_tag('table') ) {
last if $table->[1]{class} and
$table->[1]{class} eq 'item_description';
}
print $p->get_trimmed_text('/td');

--


How did you know to use $table->[1]{class} and say not $table->[0]
{class}? Is there something in the documentation that I missed?
.



Relevant Pages