Using the ultra simple XML::RSS::SimpleGen, and following step by step the example, here is a piece of code that generates an RSS feed for CPAN Ratings. It is probably pretty brittle and the main regexp could probably be improved but hey, it works!

You can run this at home, or just get the feed at http://xmltwig.com/rss/cpanratings.rss.

Comments, improvements, pointers to an existing feed... are all welcome.

Update: Du'h! Of course http://cpanratings.perl.org/index.rss already has the feed... never mind then ;--( Still, I like XML::RSS::SimpleGen.

#!/usr/bin/perl -w use strict; use XML::RSS::SimpleGen; my $VERSION=0.01; my $LIVE=1; my $url = "http://cpanratings.perl.org/"; ###################################################### # set those variables my $local_rss = "/web/infotree/rss/cpanratings.rss"; my $webmaster = 'me@localhost'; ###################################################### my $local_cache = "cpanratings.html"; my $rss = XML::RSS::SimpleGen->new( $url, "CPAN Ratings", "Ratings and + Reviews for CPAN"); $rss->language( 'en' ); $rss->webmaster( $webmaster ); $rss->twice_daily(); $rss->item_limit( 25); if( $LIVE) { $rss->get_url( $url ); } else { open( my $html, '<', $local_cache) or die "$!"; local undef $/; $_=<$html>; } while( m{<h3>\s* <a \s+ href="([^"]*)">([^<]*)</a> # $1: module URL, $2: modul +e name \s*\(([^\(]*)\) # $3: version \s*<img.*?alt="(\d) \s stars?"> # $4: rating \s*</h3> \s*<p>\s* (.*?) # $5: text (first line) (\s*<br \s* />.*?)? # $6: more lines \s*</p> \s*<p> \s*<a[^>]*>([^<]*)</a> # $7: author .*? # date, unused for now \s*<br \s* /> \s*\(<a \s+ href="/([^"]*)" # $8: url }xgs ) { my( $module_url, $module_name, $module_version, $rating, $text, $m +ore, $author, $review_url) = ($1, $2, $3, $4, $5, $6, $7, $8); my $url= "http://cpanratings.perl.org/$review_url"; my $title= "$module_name ($module_version): $rating stars - by $au +thor"; my $descr= $text; if( $more) { $descr=~ s{\s*\.*\s*$}{ ...}; } $rss->item( $url, $title, $descr); unless( $LIVE) { warn "title: '$title' - url: '$url' - descr: '$de +scr'\n"; } } $rss->save( $local_rss, 5); # the 5 means that the script wi +ll scream if the RSS does not change for 5 days in a row exit; __END__ =head1 NAME gen_rss_cpanratings - generate an RSS feed for CPAN Ratings =head1 SYNOPSYS set the top variables, then run the script from cron twice a day =head1 REQUIREMENTS Perl 5, XML::RSS::SimpleGen =head1 LICENSE This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 AUTHOR Michel Rodriguez <mirod@xmltwig.com>

In reply to RSS feed for CPAN Ratings by mirod

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.