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.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.