Created
June 29, 2012 14:58
-
-
Save syohex/3018449 to your computer and use it in GitHub Desktop.
リハビリ用
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!perl | |
use strict; | |
use warnings; | |
use Furl; | |
use XML::RSS::LibXML; | |
use Encode; | |
my $rss_url = shift or die "Usage: $0 rss_url"; | |
my $ua = Furl->new(); | |
my $res = $ua->get($rss_url); | |
unless ($res->is_success) { | |
die "Can't download $rss_url"; | |
} | |
my $parser = XML::RSS::LibXML->new; | |
eval { | |
$parser->parse($res->content); | |
}; | |
if ($@) { | |
die "Can't parse RSS!!"; | |
} | |
my $index = 1; | |
for my $item ( @{ $parser->{items} } ) { | |
printf "[%2d] :%s\n", $index++, Encode::encode_utf8($item->{title}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment