get_fail_reports
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
use Getopt::Long; | |
use IO::File; | |
use Mojo::UserAgent; | |
use XML::RSS::Parser::Lite; | |
GetOptions( | |
'd=s' => \my $directory, | |
'a=s' => \my $author, | |
's=s' => \my $since, | |
); | |
my $ua = Mojo::UserAgent->new; | |
$author ||= 'RENEEB'; | |
$author = uc $author; | |
$directory ||= '.'; | |
my $initial = substr $author, 0, 1; | |
my $url = sprintf "http://www.cpantesters.org/author/%s/%s-nopass.rss", $initial, $author; | |
my $feed = $ua->get( $url ); | |
my $parser = XML::RSS::Parser::Lite->new; | |
$parser->parse( $feed->res->body ); | |
my $count = $parser->count - 1; | |
for my $i ( 0 .. $count ) { | |
my $item = $parser->get( $i ); | |
my $title = $item->get( 'title' ); | |
my $link = $item->get( 'guid' ); | |
next if $title !~ /^FAIL/; | |
my ($id) = (split /\//, $link)[-1]; | |
my ($dist) = (split / /, $title)[1]; | |
print STDERR "$dist // $id\n"; | |
my $report = $ua->get( $link ); | |
my $fh = IO::File->new( "$directory/$dist.$id", 'w' ); | |
$fh->print( $report->res->body ); | |
$fh->close; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment