in reply to Error handling with HTML::TableExtract
#/usr/bin/perl -w use strict; use LWP; use HTML::TableExtract qw( tree ); my $ua = LWP::UserAgent->new; my ($cell_a, $cell_b, $content); my $url="http://www.heise.de"; my $response = $ua->get($url); if ($response->is_success) { $content=$response->content; } ## depth => 1, count => 0 -> 1st table in depth 1 = 1st table in docum +ent my $te=HTML::TableExtract->new(keep_html=>0, depth => 1, count => 0); $te->parse($content); ## we only have one table here... my $table= $te->first_table_found(); ## check if we really have it print "Content of cell 0,0: " . $table->cell(0,0)->as_text . "\n"; ## now that's what you were after, eh? if (defined($table->cell(0,0)) && $table->cell(0,0)->as_text =~ /heise +/) { $cell_a = $table->cell(0,1)->as_text; $cell_b = $table->cell(0,2)->as_text; } print "Cell2: $cell_a\nCell3: $cell_b\n";
|
|---|