Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: RE: seeker watch

by jeroenes (Priest)
on Apr 20, 2001 at 16:15 UTC ( #74141=note: print w/ replies, xml ) Need Help??


in reply to RE: seeker watch
in thread seeker watch

I updated the script to work with unapproved questions. I don't like to be popped, so it dumps on term only. I shamelessly copied the passwd stuff from jcwren's luke_repwalker.

#!/usr/bin/perl -w use strict; use LWP::Simple; use Getopt::Std; use URI::Escape; use constant APPROV => 'Approved'; use constant UNAPPROV => 'Unapproved'; my $poll = 60; my %question = ( APPROV, '', UNAPPROV,''); my $count = 0; $|=1; { my %args; getopts('u:p:', \%args); # Replace these dies with username/password my $user = $args{u} || 'jeroenes' || # You can put your name here die("You need to specify the user with -u"); my $pass = $args{p} || 'youdontwannaknowdoyou' || # You can put yo +ur password here die("You need to specify the password with -p"); main( $user, $pass ) while (1); } sub main { watch( @_); my @secs = times; $secs[0] += $secs[2]; $secs[1] += $secs[3]; printf "Done %5i fetch%s since last new question. CPU: %8.3f user; + %8.3f system\r", ++$count, $count>1?'es':'', @secs; sleep $poll; } sub watch { my $url = 'http://perlmonks.org/index.pl?node=Seekers%20of%20Perl% +20Wisdom'; if (@_) { my $user = uri_escape(shift); my $passwd = uri_escape(shift); $url .= "&op=login&user=$user&passwd=$passwd"; } my $content = get($url) or return; if ($content =~ m/<font color=white>User Questions<\/font>.+?<a hr +ef=\"\/index\.pl\?node_id=\S+\">(.*?)<\/a>/is) { compare( APPROV, $1); } if ($content =~ m/<font color=white>Unapproved Questions<\/font>.+ +?<a href=\"\/index\.pl\?node_id=\S+\">(.*?)<\/a>/is) { compare( UNAPPROV, $1); } } sub compare { my $state = shift; my $curquestion = shift; if ($question{$state} ne $curquestion) { $question{$state} = $curquestion; act($state); $count = 0; } } sub act { my $state = shift; print "\nNew $state PerlMonks Question: $question{$state}\n"; }
prints out some CPU info while waiting....

cheers,

Jeroen
"We are not alone"(FZ)


Comment on Re: RE: seeker watch
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (10)
As of 2015-07-31 11:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (276 votes), past polls