#!/usr/bin/perl use warnings; use strict; use WWW::Mechanize; use XML::LibXML; use constant { PM_URL => 'http://www.perlmonks.org/bare/?node_id=', # Node ids: LOGIN => 109, XP => 32704, }; print "User? "; chomp(my $user = <>); print "Pass? "; chomp(my $pass = <>); my $mech = 'WWW::Mechanize'->new; $mech->get(PM_URL . LOGIN); $mech->submit_form( form_number => 1, fields => { user => $user, passwd => $pass, }, ); my %out; my $limit = 500; my $offset = 0; while (1) { $mech->get(PM_URL . XP . ";limit=$limit;offset=$offset"); my $xml = 'XML::LibXML'->load_xml(string => $mech->content); my @nodes = $xml->findnodes('/USERNODES/NODE'); last unless @nodes; for my $node (@nodes) { my ($date, $xp) = map $node->getAttribute($_), qw(createtime reputation); substr $date, 7, length($date), q{}; # Group by month. $out{$date}{count}++; $out{$date}{sum} += $xp; } $offset += $limit; } open my $OUT, '>', 'xp.out' or die $!; for my $date (sort keys %out) { print {$OUT} "$date\t", $out{$date}{sum} / $out{$date}{count}, "\n"; } close $OUT or die $!; =for gnuplot set xdata time set timefmt '%Y-%m' set xtics format '%Y-%m' plot 'xp.out' using 1:2:(2e6) with boxes fs solid =cut