#!/usr/bin/perl -wT
use strict;
use LWP::Simple;
use XML::Simple;
use Time::Local;
use Text::BarGraph;
my $startid = shift || 85416;
my $endid = shift || 129044;
my $debug = shift || 0;
my $xmlurl = "http://perlmonks.org/index.pl?node_id=37150";
my $user = 'blakem';
my $pass = 'yeahright';
my $spansize = 500; # process nodeids in chunks of this size
## Ask the perlmonks XML engine about the nodes
my $lastid = $startid-1;
my %nodecount = map {$_=>0} ('100'..'123',
'200'..'223',
'300'..'323',
'400'..'423',
'500'..'523',
'600'..'623',
'700'..'723');
while ($lastid < $endid) {
$startid = $lastid+1;
$lastid = $endid < $lastid+$spansize ? $endid : $lastid+$spansize;
# Next line is an ugly kludge. The xml returned for just one node
# has a slightly different structure... Instead of dealing with
# it properly, I simply avoid asking for a single nodeid!
$lastid++ if $lastid-1 <= $startid;
my $queryurl = $xmlurl . '&nodes=' . join(',',$startid .. $lastid) .
"&user=$user&passwd=$pass&op=login";
print "GET $startid - $lastid\n" if $debug;
my $nodeinfo = XMLin(get $queryurl);
## Tally what hour they were posted in %nodecount
for my $node (@{$nodeinfo->{NODE}}) {
my ($year,$mon,$mday,$hours,$min,$sec) =
$node->{createtime} =~ /(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)
+/;
$year -= 1900;
$mon--;
my $time = timegm($sec,$min,$hours,$mday,$mon,$year);
$time -= 3*60*60;
my ($hour,$weekday) = (localtime($time))[2,6];
$weekday = 7 if $weekday == 0;
print $node->{node_id} .": ". localtime($time) . " => $hour\n" if
+$debug > 1;
$nodecount{sprintf("%d%02d",$weekday,$hour)}++;
}
}
# print out a bargraph
my $g = Text::BarGraph->new();
$g->{num} = 1;
print $g->graph(\%nodecount);
__END__
=head1 Sample Output from June through November of 2001
100 (144) ################
101 (143) ###############
102 (186) ####################
103 (198) ######################
104 (196) #####################
105 (264) #############################
106 (365) ########################################
107 (453) ##################################################
108 (464) ###################################################
109 (455) ##################################################
110 (433) ################################################
111 (486) ######################################################
112 (490) ######################################################
113 (483) ######################################################
114 (492) #######################################################
115 (331) #####################################
116 (274) ##############################
117 (248) ###########################
118 (175) ###################
119 (173) ###################
120 (200) ######################
121 (171) ###################
122 (136) ###############
123 (159) #################
200 (119) #############
201 (171) ###################
202 (218) ########################
203 (199) ######################
204 (238) ##########################
205 (307) ##################################
206 (380) ##########################################
207 (502) ########################################################
208 (553) ##########################################################
+###
209 (533) ##########################################################
+#
210 (503) ########################################################
211 (559) ##########################################################
+####
212 (470) ####################################################
213 (552) ##########################################################
+###
214 (407) #############################################
215 (299) #################################
216 (300) #################################
217 (212) #######################
218 (200) ######################
219 (197) ######################
220 (166) ##################
221 (158) #################
222 (174) ###################
223 (144) ################
300 (135) ###############
301 (195) #####################
302 (190) #####################
303 (207) #######################
304 (173) ###################
305 (271) ##############################
306 (416) ##############################################
307 (544) ##########################################################
+##
308 (581) ##########################################################
+######
309 (559) ##########################################################
+####
310 (507) ########################################################
311 (518) #########################################################
312 (485) ######################################################
313 (455) ##################################################
314 (465) ####################################################
315 (411) #############################################
316 (306) ##################################
317 (215) ########################
318 (215) ########################
319 (171) ###################
320 (183) ####################
321 (162) ##################
322 (152) #################
323 (143) ###############
400 (132) ##############
401 (222) ########################
402 (190) #####################
403 (201) ######################
404 (207) #######################
405 (317) ###################################
406 (418) ##############################################
407 (536) ##########################################################
+#
408 (562) ##########################################################
+####
409 (608) ##########################################################
+##########
410 (494) #######################################################
411 (524) ##########################################################
412 (563) ##########################################################
+####
413 (527) ##########################################################
414 (466) ####################################################
415 (416) ##############################################
416 (277) ##############################
417 (241) ##########################
418 (207) #######################
419 (193) #####################
420 (162) ##################
421 (167) ##################
422 (144) ################
423 (149) ################
500 (154) #################
501 (186) ####################
502 (249) ###########################
503 (187) ####################
504 (193) #####################
505 (277) ##############################
506 (375) #########################################
507 (480) #####################################################
508 (539) ##########################################################
+##
509 (477) #####################################################
510 (448) ##################################################
511 (505) ########################################################
512 (528) ##########################################################
+#
513 (459) ###################################################
514 (390) ###########################################
515 (312) ##################################
516 (276) ##############################
517 (190) #####################
518 (145) ################
519 (133) ##############
520 (149) ################
521 (112) ############
522 (103) ###########
523 (109) ############
600 ( 61) ######
601 ( 87) #########
602 ( 68) #######
603 ( 71) #######
604 ( 76) ########
605 ( 84) #########
606 (111) ############
607 (134) ##############
608 (174) ###################
609 (174) ###################
610 (151) ################
611 (160) #################
612 (145) ################
613 (177) ###################
614 (149) ################
615 (143) ###############
616 (120) #############
617 (120) #############
618 (116) ############
619 (126) ##############
620 (118) #############
621 (108) ############
622 ( 84) #########
623 (103) ###########
700 ( 82) #########
701 ( 74) ########
702 ( 61) ######
703 ( 76) ########
704 ( 63) #######
705 ( 84) #########
706 ( 98) ##########
707 ( 97) ##########
708 (152) #################
709 (143) ###############
710 (188) #####################
711 (204) ######################
712 (166) ##################
713 (172) ###################
714 (160) #################
715 (171) ###################
716 (146) ################
717 (157) #################
718 (159) #################
719 (152) #################
720 (182) ####################
721 (123) #############
722 (135) ###############
723 (115) ############
|