This is my code to extract certain data under the header Item Drop%
. I want to extract the 90.5%
under that header. But i can only extract the whole column not just that value. any idea ?
#!/usr/bin/perl
use strict;
use warnings;
use HTML::TableExtract;
use LWP::Simple;
my $file = 'data.html';
unless ( -e $file ) {
my $rc = getstore(
'proj/Desktop/folder1/data.html',
$file);
die "Failed to download document\n" unless $rc == 200;
}
my $te = HTML::TableExtract->new( headers => qw(Item Drop%)]);
$te->parse_file($file);
my ($table) = $te->tables;
foreach my $ts (ts->tables) {
print "Table (", join(',', $ts->coords), ");\n";
foreach my $row ($ts->rows) {
print join(',', @$row), "\n";
}
}
My data.html
is:
..
..
..
<table align = "center" class="" style= .......>
<tr>
<th rowspan="2">EM</th>
<th colspan="2"><a href= "proj/Desktop/folder1/data.html" class = ..../th>
<td> 90.5%</td>
</tr>
..
..
..
..
<tr>
<th rowspan="2">EM</th>
<th colspan="2"><a href= "proj/Desktop/folder1/data.html" class = ..../th>
<td> 40%</td>
</tr>
</table>
attribs
orheaders
from the constructor.($te->tables)[1]
etc.