Parse of rss feeds
January 19th, 2006Category: My LifeОт много време на страницата ми има разни новини и хората чат пат ме питат как ги обновявам и т.н.
Ето как:
Трябва да стартирате следната команда:
perl parse.pl adresa.na.rss.feed
като в parse.pl има:
#!/usr/bin/perl -w
# Setup includes
use strict;
use XML::RSS;
use LWP::Simple;
# Declare variables for URL to be parsed
my $url2parse;
# Get the command-line argument
my $arg = shift;
# Create new instance of XML::RSS
my $rss = new XML::RSS;
# Get the URL, assign it to url2parse, and then parse the RSS content
$url2parse = get($arg);
die "Could not retrieve $arg" unless $url2parse;
$rss->parse($url2parse);
# Print the channel items
my $i=0;
foreach my $item (@{$rss->{'items'}}) {
if ($i>20){
print "...";
exit;
}
next unless defined($item->{'title'}) && defined($item->{'link'});
print "• <a xhref=\"$item->{'link'}\">$item->{'title'}</a><br />\n";
$i++;
}
Leave a Reply
Georgi’s Blog is proudly powered by
WordPress
Постове (RSS)
and Коментари (RSS).

20 queries. 0.538 seconds.

