HTML::TableExtract example

HTML::TableExtract example

am 24.11.2005 00:12:45 von stevefink

------=_Part_10190_31670081.1132787565877
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

Hi all,

I've completed this using regular expressions parsing out arbitrary data
between HTML tag, however I found a much more efficient route with the
HTML::TableExtract module which looks like it can very well shorten my code
and make it more manageable. I'm able to parse out the entire table with
the following code:

#!/usr/bin/perl -w -t
# Development grounds for using HTML::TableExtract for songsearch.pl

use HTML::TableExtract;
use strict;

my $html =3D 'latest_rel.htm';

my $te =3D HTML::TableExtract->new( attribs =3D> { border =3D> 1 } );
$te->parse_file($html);

foreach my $ts ($te->tables) {
foreach my $row ($ts->rows) {
print " ", join(',' , @$row), "\n";
}
}

However, now I want to extract only the second column from this table (It
just consists of several rows with three columns).

Any hints would be greatly appreciated!

Thanks and have a great holiday weekend.


--
Steve Finkelstein
stevefink@gmail.com

------=_Part_10190_31670081.1132787565877--

Re: HTML::TableExtract example

am 28.11.2005 21:47:04 von tbrannon

On Wed, 2005-11-23 at 18:12 -0500, Steve Finkelstein wrote:

>
> However, now I want to extract only the second column from this table (It
> just consists of several rows with three columns).

That's easy with HTML::TreeBuilder. HTML::Element in the distro has a
look_down method which would help. The ->guts() method would also be
useful.