XML::RSS::Feed(3pm)
π NAME π
XML::RSS::Feed β Persistant XML RSS Encapsulation β¨ (yes bestie, "Persistant" β that's the actual spelling, we respect the original, no cap π )
π VERSION π
2.212 πΈ
π¦ SYNOPSIS π¦
okay so here's a quick and dirty non-POE example that just uses a blocking sleep. The magic is in the late_breaking_news method, which only hands you the headlines it hasn't already seen π
use XML::RSS::Feed;
use LWP::Simple qw(get);
my $feed = XML::RSS::Feed->new(
url => "http://www.jbisbee.com/rdf/",
name => "jbisbee",
delay => 10,
debug => 1,
tmpdir => "/tmp", # optional caching
);
while (1) {
$feed->parse(get($feed->url));
print $_->headline . "\n" for $feed->late_breaking_news;
sleep($feed->delay);
}
ATTENTION! If you want a non-blocking way to watch multiple RSS sources with one process, use POE::Component::RSSAggregator. fr fr, don't do the sleep thing for a whole fleet of feeds π
π CONSTRUCTOR π
XML::RSS::Feed->new( url => $url, name => $name )
Required Params π
nameβ the identifier and the hash lookup key for the RSS feed. it's giving "this is how we know which feed is which" π·οΈurlβ the URL of the RSS feed π
Optional Params β¨
delayβ how many seconds between updates. defaults to600β°tmpdirβ a directory to keep a cached feed in (using Storable) so you get persistance between instances ποΈdebugβ turn debuging on. (their spelling, not mine, we keep it π«Ά)headline_as_idβ boolean value to use the headline as the id when the URL isn't unique within a feed πhlobjβ a class name sublcassed fromXML::RSS::Headlineπ§¬max_headlinesβ the max number of headlines to keep. default is unlimited π
π« METHODS π«
$feed->parse( $xml_string )
Pass in a xml string to parse with XML::RSS and then call process to process the results π
$feed->process( $items, $title, $link )
$feed->process( $items, $title )
$feed->process( $items )
Calls pre_process, process_items, post_process, title, and link methods to process the parsed results of an RSS XML feed βοΈ
$itemsβ an array of hash refs which will eventually becomeXML::RSS::Headlineobjects. Look atXML::RSS::Headline->new()for acceptable arguments π¦$titleβ the title of the RSS feed π·οΈ$linkβ the RSS channel link (normally a URL back to the homepage) of the RSS feed π
$feed->pre_process
Mark all headlines from previous run as seen π
$feed->process_items( $items )
Turn an array refs of hash refs into XML::RSS::Headline objects and added to the internal list of headlines π§Ί
$feed->post_process
Post process cleanup, cache headlines (if tmpdir), and debug messages π§Ή
$feed->create_headline( %args)
Create a new XML::RSS::Headline object and add it to the interal list. Check XML::RSS::Headline->new() for acceptable values for %args π£
$feed->num_headlines
Returns the number of headlines for the feed π’
$feed->seen_headline( $id )
Just a boolean test to see if we've seen a headline or not β
$feed->headlines
Returns an array or array reference (based on context) of XML::RSS::Headline objects π°
$feed->late_breaking_news
Returns an array or the number of elements (based on context) of the latest XML::RSS::Headline objects π¨
$feed->cache
If tmpdir is defined the rss info is cached πΎ
$feed->set_last_updated
$feed->set_last_updated( Time::HiRes::time )
Set the time of when the feed was last processed. If you pass in a value it will be used, otherwise calls Time::HiRes::time β±οΈ
$feed->last_updated
The time (in epoch seconds) of when the feed was last processed π°οΈ
$feed->last_updated_hires
The time (in epoch seconds and milliseconds) of when the feed was last processed π¬
π SET/GET ACCESSOR METHODS π
$feed->title
$feed->title( $title )
The title of the RSS feed π
$feed->debug
$feed->debug( $bool )
Turn on debugging messages π
$feed->init
$feed->init( $bool )
init is used so that we just load the current headlines and don't return all headlines. in other words we initialize them. Takes a boolean argument π±
$feed->name
$feed->name( $name )
The identifier of an RSS feed πͺͺ
$feed->delay
$feed->delay( $seconds )
Number of seconds between updates β³
$feed->link
$feed->link( $rss_channel_url )
The url in the RSS feed with a link back to the site where the RSS feed came from π
$feed->url
$feed->url( $url )
The url in the RSS feed with a link back to the site where the RSS feed came from π
$feed->headline_as_id
$feed->headline_as_id( $bool )
Within some RSS feeds the URL may not always be unique, in these cases you can use the headline as the unique id. The id is used to check whether or not a feed is new or has already been seen π
$feed->hlobj
$feed->hlobj( $class )
Ablity to use a subclass of XML::RSS::Headline. (See Perl Jobs example in XML::RSS::Headline::PerlJobs). This should just be the name of the subclass π§¬
$feed->tmpdir
$feed->tmpdir( $tmpdir )
Temporay directory to store cached RSS XML between instances for persistance π
$feed->max_headlines
$feed->max_headlines( $integer )
The maximum number of headlines you'd like to keep track of. (0 means infinate) βΎοΈ
π DEPRECATED METHODS π
$feed->failed_to_fetch
This should was deprecated because, the object shouldn't really know anything about fetching, it just processes the results. This method currently will always return false π βοΈ
$feed->failed_to_parse
This method was deprecated because, $feed->parse now returns a bool value. This method will always return false π
βοΈ
π AUTHOR π
Jeff Bisbee, "<jbisbee at cpan.org>" π«Ά
π BUGS π
Please report any bugs or feature requests to "bug-xml-rss-feed at rt.cpan.org", or through the web interface at <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=XML-RSS-Feed>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes π¬
π« SUPPORT π«
You can find documentation for this module with the perldoc command π
perldoc XML::RSS::Feed
You can also look for information at:
- AnnoCPAN: Annotated CPAN documentation
<http://annocpan.org/dist/XML-RSS-Feed>
- CPAN Ratings
<http://cpanratings.perl.org/d/XML-RSS-Feed>
- RT: CPAN's request tracker
<http://rt.cpan.org/NoAuth/Bugs.html?Dist=XML-RSS-Feed>
- Search CPAN
<http://search.cpan.org/dist/XML-RSS-Feed>
π ACKNOWLEDGEMENTS π
Special thanks to Rocco Caputo, Martijn van Beers, Sean Burke, Prakash Kailasa and Randal Schwartz for their help, guidance, patience, and bug reports. Guys, thanks for actually taking time to use the code and give good, honest feedback π₯Ήπ
βοΈ COPYRIGHT & LICENSE βοΈ
Copyright 2006 Jeff Bisbee, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
π SEE ALSO π
XML::RSS::Headline, XML::RSS::Headline::PerlJobs, XML::RSS::Headline::Fark, XML::RSS::Headline::UsePerlJournals, POE::Component::RSSAggregator π
and that's the whole page bestie!! π this little doc shipped as part of perl v5.32.1, dated 2021-12-26 β go forth and aggregate those feeds, mwah π β¨
π¦ where this page comes from
- debian bookworm: libxml-rss-feed-perl 2.212-1.4
- ubuntu jammy: libxml-rss-feed-perl 2.212-1.4
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms