Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re: Abstract: rate of popular growth for Perl

by Limbic~Region (Chancellor)
on Jan 11, 2005 at 21:26 UTC ( #421440=note: print w/replies, xml ) Need Help??

in reply to Abstract: rate of popular growth for Perl

You need to choose a tangible set of factors to measure since the concept of "popular" is very subjective. One ruler might be the population growth of a particular community such as Perl Monks. To that end, the following piece of code will extract dates and counts for approximately the first 550 new users.

Please do not modify this code and run it without thinking about the consequences. The sleep interval is likely not long enough if you are going to hammer jcwren's server for every single user. Another useful feature would be to have signal handling allowing persistency of data (DB) even when you abort early. Additionally, it should be modified to allow you to resume where it left off. This would make gathering the stats over time much more server friendly.

#!/usr/bin/perl use strict; use warnings; use HTML::TableContentParser; use WWW::Mechanize; use constant DATE => 3; use constant STATS => 4; my %opt = ( url => ' +13&sortlist=1,3&', end => 500, pos => 0, ); my $mech = WWW::Mechanize->new( autocheck => 1 ); my %date; while ( $opt{pos} <= $opt{end} ) { $mech->get( $opt{url} . '&start=' . $opt{pos} ); my $table = HTML::TableContentParser->new()->parse( $mech->content +() ); for my $row ( @{ $table->[ STATS ]{rows} } ) { my $stamp = ${ $row->{cells} }[ DATE ]{data}; next if ! $stamp; ($stamp) = $stamp =~ m|<NOBR>(.*)</NOBR>|; $date{ substr($stamp, 0, 10) }++; } $opt{pos} += 50; select(undef, undef, undef, 0.75); } print "$_,$date{$_}\n" for sort keys %date;
In reality, you would want to consider more factors like the ratio of writeups to users, how many users haven't logged in for more than a certain amount of time, etc.

Cheers - L~R

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://421440]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (6)
As of 2017-05-26 11:41 GMT
Find Nodes?
    Voting Booth?