AnyEvent::Feed(3pm) | User Contributed Perl Documentation | AnyEvent::Feed(3pm) |
AnyEvent::Feed - Receiving RSS/Atom Feed reader with XML::Feed
Version 0.3
use AnyEvent; use AnyEvent::Feed; my $feed_reader = AnyEvent::Feed->new ( url => 'http://example.com/atom.xml', ); $feed_reader->fetch (sub { my ($feed_reader, $new_entries, $feed, $error) = @_; if (defined $error) { warn "ERROR: $error\n"; return; } # $feed is the XML::Feed object belonging to that fetch. for (@$new_entries) { my ($hash, $entry) = @$_; # $hash a unique hash describing the $entry # $entry is the XML::Feed::Entry object of the new entries # since the last fetch. } }); # Or: my $feed_reader = AnyEvent::Feed->new ( url => 'http://example.com/atom.xml', interval => $seconds, on_fetch => sub { my ($feed_reader, $new_entries, $feed, $error) = @_; if (defined $error) { warn "ERROR: $error\n"; return; } # see above } );
This module implements some glue between AnyEvent::HTTP and XML::Feed. It can fetch a RSS/Atom feed on a regular interval as well as on customized times. It also keeps track of already fetched entries so that you will only get the new entries.
$feed_reader is the feed reader object itself. $new_entries is an array reference containing the new entries. A new entry in that array is another array containing a calculated hash over the contents of the new entry, and the XML::Feed::Entry object of that entry. $feed_obj is the XML::Feed feed object used to parse the fetched feed and contains all entries (and not just the 'new' ones).
What a 'new' entry is, is decided by a map of hashes as described in the "entry_ages" method's documentation above.
Robin Redeker, "<elmex@ta-sa.org>"
XML::Feed
AnyEvent::HTTP
AnyEvent
There is actually a known bug with encodings of contents of Atom feeds. XML::Atom by default gives you UTF-8 encoded data. You have to set this global variable to be able to use the XML::Feed::Entry interface without knowledge of the underlying feed type:
$XML::Atom::ForceUnicode = 1;
I've re-reported this bug against XML::Feed, as I think it should take care of this. XML::Atom should probably just fix it's Unicode interface, but it seems to be a bit deserted w.r.t. fixing the bugs in the tracker.
Please report any bugs or feature requests to "bug-anyevent-feed at rt.cpan.org", or through the web interface at <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=AnyEvent-Feed>. I will be notified and then you'll automatically be notified of progress on your bug as I make changes.
You can find documentation for this module with the perldoc command.
perldoc AnyEvent::Feed
You can also look for information at:
See the same channel as the AnyEvent::XMPP module:
IRC Network: http://freenode.net/ Server : chat.freenode.net Channel : #ae_xmpp Feel free to join and ask questions!
<http://annocpan.org/dist/AnyEvent-Feed>
<http://cpanratings.perl.org/d/AnyEvent-Feed>
<http://rt.cpan.org/NoAuth/Bugs.html?Dist=AnyEvent-Feed>
<http://search.cpan.org/dist/AnyEvent-Feed>
Copyright 2009 Robin Redeker, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
2021-01-01 | perl v5.32.0 |