ダウンロードした HTML を STDIN に渡し、テーブル マークアップ以外のすべてのタグを削除しています。table、tr、および td の残りのインスタンスに基づいてテーブルをレンダリングしたいので、テーブルは "\t" または "|" になります。区切られています。ASCII 形式のテーブルも機能します。以下は私がこれまでに持っているものですが、それは仕事を成し遂げません:
#!/usr/bin/perl -ws
use HTML::Scrubber;
use HTML::Entities qw(decode_entities);
use Text::Unidecode qw(unidecode);
my $HTMLinput = do {local $/; <STDIN>};
my $scrubber = HTML::Scrubber->new( allow => [ qw[ table tr td ] ] );
#this prints the text from the page, but without formatting tables in ASCII:
#print $scrubber->scrub($HTMLinput);
my $scrubber2 = $scrubber->scrub($HTMLinput);
#was hoping this would remove transform table, tr, and td-tagged content
#into ASCII-formatted tables, but it doesn't work:
print unidecode(decode_entities($scrubber2)), "\n";
#test page: http://www.w3schools.com/html/html_tables.asp
#curl http://www.w3schools.com/html/html_tables.asp | html.table.parser.pl