Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

RE: seeker watch

by kilinrax (Deacon)
on Sep 26, 2000 at 19:12 UTC ( [id://34020]=note: print w/replies, xml ) Need Help??

in reply to seeker watch

Here's an x-windows version, with slight adjustments.
#!/usr/bin/perl -w use strict; use LWP::Simple; my $poll = 60; my $question = {}; { &watch; sleep $poll; redo; } sub watch { my $content = get(' +%20Perl%20Wisdom'); if ($content =~ /<font color=white>User Questions<\/font>.+?<a hre +f=\"\/index\.pl\?node_id=\S+\">(.*?)<\/a>/is) { compare($1); } } sub compare { my $curquestion = shift; if ($question ne $curquestion) { $question = $curquestion; &act; } } sub act { system "xmessage \"New PerlMonks Question: $question\""; }

Replies are listed 'Best First'.
Re: RE: seeker watch
by jeroenes (Priest) on Apr 20, 2001 at 16:15 UTC
    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 = ' +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....


    "We are not alone"(FZ)

Log In?

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2024-05-28 05:24 GMT
Find Nodes?
    Voting Booth?

    No recent polls found