root/misc/cpan-ratings.pl

Revision 2948 (checked in by miyagawa, 10 years ago)

use env perl

  • Property svn:executable set to *
Line 
1 #!/usr/bin/env perl
2 use strict;
3 use warnings;
4
5 use LWP::UserAgent;
6 use XML::RSS;
7
8 my $id = $ARGV[0] or die "Usage: cpan-ratins.pl YOUR-CPAN-ID\n";
9 my $ua = LWP::UserAgent->new;
10
11 my $html = $ua->get("http://search.cpan.org/~$id/")->content;
12 my @dist = $html =~ m!href="/src/$id/(.*?)-[\d\.]+/">Browse</a>!gi;
13
14 for my $dist (@dist) {
15     print "[$dist]\n";
16     my $url = "http://cpanratings.perl.org/dist/$dist";
17     my $xml = $ua->get("$url.rss")->content;
18     my $rss = XML::RSS->new;
19     eval { $rss->parse($xml) };
20     next if $@;
21
22     for my $item (@{$rss->{items}}) {
23         my $star = ($item->{description} =~ /Rating: (\d) star/)[0] || 0;
24         print( ("*") x $star, (" ") x (5 - $star), " by ", $item->{dc}->{creator}, "\n" );
25     }
26
27     if (@{$rss->{items}}) {
28         print "  $url\n";
29     }
30 }
31
32
Note: See TracBrowser for help on using the browser.