Sooo... My HTML::TableExtract method doesnt seem to be working when I try to parse html strings...
sub Parse{ my $self = shift; my $html_code = shift; my $te = HTML::TableExtract->new( headers => [qw(Severity Advi +sory Synopsis Date)] ); my @args = (); $te->parse($html_code); foreach my $ts($te->tables) { foreach my $row ($ts->rows) { push(@args,("\'".join('\',\'',@$row)."\'\n")); } } return @args; }
That code will not work... I have debugged it in eclipsed and watched the program put the source code correctly into the parser as I would imagine it should. When the dubugger gets to the foreach loops, it skips right over them because the parser did not grab any data from the HTML code to iterate. If I save the same source code as an HTML and use this:
sub Parse{ my $self = shift; my $html_code = shift; my $te = HTML::TableExtract->new( headers => [qw(Severity Advi +sory Synopsis Date)] ); my @args = (); $te->parse_file('blah.html'); foreach my $ts($te->tables) { foreach my $row ($ts->rows) { push(@args,("\'".join('\',\'',@$row)."\'\n")); } } return @args; }
...replacing parse with parse_file and the name of the html file which contains the same code input into parse originally, I get the correct output... For the first code segment which parses an html string, lets assume that the string contains the source code from http://rhn.redhat.com/errata/rhel-server-6-errata-security.html. Am I misunderstanding what an HTML string is ??? What am I doing wrong great Monks of Wisdom???
In reply to Problem with HTML::TableExtract by jayto
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |