@kyanny's blog

My thoughts, my life. Views/opinions are my own.

HTML::ExtractContent サンプル

http://gist.github.com/114166

#!/usr/bin/perl
use strict;
use warnings;
use HTML::ExtractContent;
use Encode;
use Encode::Detect;
use Perl6::Say;
use Getopt::Long;
use Pod::Usage;
my $help;
GetOptions(
    'help' => \$help,
) or pod2usage(2);
$help and pod2usage(2);

my $html = do { local $/; <> };
my $decoded_html = decode('Detect', $html);
my $extractor = HTML::ExtractContent->new;
$extractor->extract($decoded_html);
say $extractor->as_text;


__END__

=head1 NAME

content_extract.pl - 

=head1 SYNOPSIS

  $ curl http://blog.livedoor.jp/tabbata/archives/50684381.html | ./content_extract.pl

=head1 DESCRIPTION



=cut

はてなダイアリーに gist 埋め込みたいなー