Skip to content

Instantly share code, notes, and snippets.

@kiyotakagoto
Created November 21, 2011 03:50
Show Gist options
  • Select an option

  • Save kiyotakagoto/1381564 to your computer and use it in GitHub Desktop.

Select an option

Save kiyotakagoto/1381564 to your computer and use it in GitHub Desktop.
HTML::ExtractContentで本文抽出
sub url2text{
my $url = shift;
my $ua = LWP::UserAgent->new;
my $res = $ua->get( $url );
if( $res->is_error ){
print 'some error: ', $res->status_line;
}
my $html = $res->decoded_content;
my $ex = HTML::ExtractContent->new;
$ex->extract( $html );
return $ex->as_text;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment