Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
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)


In reply to Re: RE: seeker watch by jeroenes
in thread seeker watch by vladdrak

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others lurking in the Monastery: (3)
    As of 2014-09-20 15:27 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      How do you remember the number of days in each month?











      Results (160 votes), past polls