Mysql
 SQL >> Database >  >> RDS >> Mysql

Estrarre tabelle HTML con Perl HTML::TableExtract

HTML::TableExtract può analizzare le righe delle tabelle in record strutturati. Dopo aver rimosso gli spazi bianchi, dividi le celle multilinea in campi e scrivi l'output CSV.

my $te = HTML::TableExtract->new(); $te->parse($html); foreach my $ts ($te->table_states) { foreach my $row ($ts->rows) { s/^\s+//, s/\s+$// for @$row; $csv->combine(@$row); print $csv->string, "\n"; } }

Usa Text::CSV per gestire in modo affidabile quoting ed escaping.