XML::FeedLite - Perl extension for fetching Atom and RSS feeds with minimal outlay
$Revision: 1.9 $
use XML::FeedLite;
This module fetches and processes Atom and RSS-format XML feeds. It's designed as an alternative to XML::Atom, specifically to work better under mod_perl. This module requires LWP::Parallel::UserAgent.
my $xfl = XML::FeedLite->new('http://www.atomenabled.org/atom.xml'); my $xfl = XML::FeedLite->new([qw(http://www.atomenabled.org/atom.xml http://slashdot.org/slashdot.rss)]); my $xfl = XML::FeedLite->new({ timeout => 60, url => 'http://www.atomenabled.org/atom.xml', http_proxy => 'http://user:pass@webcache.local.com:3128/', }); Options can be: url (optional scalar or array ref, URLs of feeds) timeout (optional int, HTTP fetch timeout in seconds) http_proxy (optional scalar, web cache or proxy if not set in %ENV) proxy_user (optional scalar, username for authenticating forward-proxy) proxy_pass (optional scalar, password for authenticating forward-proxy) user_agent (optional scalar, User-Agent HTTP request header value) Very often you'll want to use XML:::FeedLite::Normalised instead of this baseclass.
$xfl->http_proxy("http://user:pass@squid.myco.com:3128/");
This is only required if the username wasn't specified when setting http_proxy $xfl->proxy_user('myusername');
This is only required if the password wasn't specified when setting http_proxy $xfl->proxy_pass('secretpassword');
$xfl->user_agent('Feedtastic/1.0');
$xfl->timeout(30);
$xfl->url('http://das.ensembl.org/das/ensembl1834/'); # give url (scalar or arrayref) here if not specified in new() Or, if you want to add to the existing url list and you're feeling sneaky... push @{$xfl->url}, 'http://my.server/das/additionalsource';
$xfl->reset();
my $entry_data = $xfl->entries();
my $hrMeta = $xfl->meta(); my $hrFeedMeta = $xfl->meta('http://mysite.com/feed.xml');
my $title = $xfl->title($feed);
$xfl->fetch({ ######### # URLs and associated callbacks # 'url1' => sub { ... }, 'url2' => sub { ... }, }, { ######### # Optional HTTP headers # 'X-Forwarded-For' => 'a.b.c.d', });
my $code = $xfl->statuscodes($url); my $code_hashref = $xfl->statuscodes();
$xfl->max_req(5); print $xfl->max_req();
Roger Pettett, <rmp@psyphi.net>
Copyright (C) 2010 by Roger Pettett
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.4 or, at your option, any later version of Perl 5 you may have available.
To install XML::FeedLite, copy and paste the appropriate command in to your terminal.
cpanm
cpanm XML::FeedLite
CPAN shell
perl -MCPAN -e shell install XML::FeedLite
For more information on module installation, please visit the detailed CPAN module installation guide.