Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Playing with PerlMonks site (0) - See what user was more active

by gmpassos (Priest)
on Jul 25, 2002 at 06:31 UTC ( [id://185134]=sourcecode: print w/replies, xml ) Need Help??
Category: PerlMonks Related Scripts
Author/Contact Info Graciliano M. P.
Description: Let's play with the PerlMonks site (code 0). This code get the page "Newest Nodes", see what users have posted, count the number of nodes, and show a list of user by activity.

#####################################
# PLAY WITH THE PERLMONKS SITE (0). #
#####################################

use LWP::Simple ;

$|=1;

my $numdays = 1 ;
my $url = "http://www.perlmonks.org/index.pl?node_id=3628&numdays=$num
+days" ;

print "Getting Newest Nodes...\n" ;
print "$url\n" ;

$html = get($url);
$html =~ s/\r\n?/\n/gs ;
$html =~ s/<.*?>//gs ;

my (@users) = ( $html =~ /by\s+(\w+)\s*\n/gsi );

my %users ;
foreach my $users_i ( @users ) { $users{$users_i}++ ;}

my $total_usr ;
my $nodes = @users ;

print "-----------------------------\n" ;
foreach my $Key ( sort {$users{$b} <=> $users{$a}} keys %users ) {
  my $Value = $users{$Key} ;
  print "$Key = $Value\n" ;
  $total_usr++ ;
}
print "-----------------------------\n" ;
print "Total users: $total_usr\n" ;
print "Nodes: $nodes\n" ;
# Send your feedback!
#
# "The creativity is the expression of the liberty".
Replies are listed 'Best First'.
Re: Playing with PerlMonks site (0) - See what user was more active
by Chady (Priest) on Jul 25, 2002 at 10:15 UTC
      Agreed.. and I using XML::Simple, it takes about 5 minutes to have a working client that does interesting stuff with the tickers and doesn't use quick&dirty regexing-HTML tricks.

      Makeshifts last the longest.

Re: Playing with PerlMonks site (0) - See what user was more active
by jmcnamara (Monsignor) on Jul 25, 2002 at 08:31 UTC

    Nice idea. :-)

    When I ran the program I noticed that some users were missing from the list. This is due to the regex that extracts the usernames. This is a bit better:

    # Don't strip the tags #$html =~ s/<.*?>//gs ; my (@users) = $html =~ /<td>by\s[^>]+>([^<]+)/gs ; # Or this if there are Perlmonks with "<" in their username my (@users) = $html =~ m[<td>by\s[^>]+>(.*?)</a>]gs ;

    --
    John.

      Well, I just made it for fun. About the tags, if the user has < or > in the username, I think that the system show this in the html source like &lt; and &gt;, or we cant see this in the browser! Thanks for the reply! Make your code for "Playing with PerlMonks site" too.

      "The creativity is the expression of the liberty".

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2025-06-17 01:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.