Here is a small program that extracts all the list-items from the HTML:
use Modern::Perl;
use HTML::PullParser;
use Data::Dump qw/dump/;
my $document_to_parse = 'html_1.html';
my $p = HTML::PullParser->new(
file => $document_to_parse,
start => '"S", tagname, text',
end => '"E", tagname, text',
text => '"T", text',
) or die "Error: $!";
my @data;
my $text = '';
while ( my $token = $p->get_token ) {
if ( ( $token->[0] eq 'S' and $token->[1] eq 'ul' )
.. ( $token->[0] eq 'E' and $token->[1] eq 'ul' ) )
{
if ( $token->[0] eq 'T' ) {
$token->[1] =~ s/(\s*)$//g;
$text .= "$token->[1] " if $token->[1];
}
if ( ( $token->[0] eq 'S' and $token->[1] eq 'li' )
or ( $token->[0] eq 'E' and $token->[1] eq 'ul' ) )
{
$text =~ s/(\s*)$//g;
push @data, $text if $text;
$text = '';
}
}
}
say dump(@data);
It returns the following from the first HTML:
2 MB Fast RAM expansion
connects to the 40 pin expansion header of the Commodore A570
four 1M×4 chips soldered on board
disable jumper
nothing else is required to be on the board as the multiplexing circui
+t is already in the A570
Photo front side
And for the second HTML:
processor
68EC030 @ 40 MHz or 68030 @ 33 / 50 MHz, PGA
optional 68882 PGA FPU
memory
one 72 pin SIMM socket accepts 32 MB RAM
supports 4, 8, 16, 32 MB SIMMs, 60-70 ns
burst RAM access
optional modules
SCSI controller
NCR 53C80 controller IC
does not use DMA transfer
autoboot ROM (csascsi.device)
DB25 external SCSI connector
supported by NetBSD and OpenBSD
Photo front side back side
Software Twelve_Gauge_U62.bin (32 kB) firmware v1.0 22162A / R1.0 / 08
+74
The matter got a bit complicated because the
<LI> tags were not closed and inside some of the list items are other tags, so some re-assembly needed to be done.
I have no idea how you want to handle the lists-inside-lists thing, so I just ignored this and made these into one flat array.
CountZero
A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James