Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Abstract: rate of popular growth for Perl

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


in reply to Abstract: rate of popular growth for Perl

Tommy,
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 => 'http://tinymicros.com/pm/index.php?goto=monkstats&sortopt= +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?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://421440]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2024-04-18 03:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found