PerlでのRSS読込

投稿者:

XML::RSS と LWP::Simple を使えばすごく簡単にできます
#!C:\Perl\bin\perl
#!/usr/bin/perl
use strict;
use Jcode;
use Encode;
use LWP::Simple;
use XML::RSS;
my $rss = new XML::RSS;
my $url = “http://www.nikkeibp.co.jp/index.rdf”;
my $dat = get($url);
$rss->parse($dat);
my $channel = $rss->{‘channel’};
print “Content-type: text/plain; charset=UTF-8\n\n”;
print $channel->{‘title’};
print “
“;
print “
“;
foreach my $item( @{$rss->items}){
print $item->{‘title’};
print “
“;
print $item->{‘link’};
print “
“;
if( $item->{‘description’} ){
print $item->{‘description’};
print “
“;
print “
“;
}
}
exit;

Thank you for reading this post, don't forget to subscribe!