Somebody on dilbert.com (might have been Scott Adams) was looking for an application that would set a browser to cycle through a list of sites until the user clicked on the page to read it. This bugged me off and on for over a year.

The logic is simple. The easiest way would be using JavaScript and frames. Of course, I have better things to do with my time than staring at a monitor waiting to click when somebody posts new content. I wanted the computer to do the work and let me know when a page changed.

Between redsquirrel's recent Auto-Surfer, an old post from kilinrax, and The Mouse Book, I put together the following:

#!/usr/bin/perl -w use strict; use LWP::UserAgent; my $pageNew; # I used the US version of http://www.theregister.co.uk/ as an example my $siteName = 'http://www.theregus.com'; my $ua = LWP::UserAgent->new; my $request = HTTP::Request->new('GET', "$siteName"); my $pageOld = $ua->request($request); while() { sleep 1800; # 30 Minutes $pageNew = $ua->request($request); if ($pageOld->content ne $pageNew->content) { system('konqueror', $siteName)==0 or die "Unable to open browser\n"; $pageOld = $pageNew; } }

I know what you are thinking: 'Hooray! Good for ol' Bilfurd!' and possibly 'Get the net, another loony found a keyboard!' You forgot my favorite - 'Here's proof that the Mac made using a PC so easy even an idiot can do it.'

I actually found a use for this involving a luser (I took his keyboard away once already...) and an intranet page showing web statistics. I have a few questions before I install it on his PC:

It should be interesting to see what the monks' collective wisdom yields on this one...

In reply to Simple LWP Exercise by bilfurd

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!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • 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, details, 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, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            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.