#!/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{

\s* ([^<]*) # $1: module URL, $2: module name \s*\(([^\(]*)\) # $3: version \s* # $4: rating \s*

\s*

\s* (.*?) # $5: text (first line) (\s*
.*?)? # $6: more lines \s*

\s*

\s*]*>([^<]*) # $7: author .*? # date, unused for now \s*
\s*\(item( $url, $title, $descr); unless( $LIVE) { warn "title: '$title' - url: '$url' - descr: '$descr'\n"; } } $rss->save( $local_rss, 5); # the 5 means that the script will 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