This is the first time that I've used LWP to process some simple requests. Here's the code:
use strict; require LWP::UserAgent; my $ua = LWP::UserAgent->new (env_proxy => 1, keep_alive => 1, timeout => 30); while(<DATA>) { chomp; my $req = HTTP::Request->new('GET', $_); my $resp = $ua->request($req); if ($resp->is_success) { # print $resp->content; print "OK -----> '", $_, "'\n"; } else { print "FAILED -> '" ,$_, "'\n"; } select((select(STDOUT), $| = 1)[0]); #flush STDOUT buffer } print "Finished.\n" __DATA__ http://www.thehungersite.com/cgi-bin/WebObjects/CTDSites.woa/60/wo/SJ5 +0004g800Ig400Xz/0.0.33.13.0.1.0.0.0.CustomContentActiveImageDisplayCo +mponent.0.0.0 http://www.thebreastcancersite.com/cgi-bin/WebObjects/CTDSites.woa/60/ +wo/SJ50004g800Ig400Xz/2.0.33.13.0.1.0.1.0.CustomContentActiveImageDis +playComponent.0.0.0 http://www.therainforestsite.com/cgi-bin/WebObjects/CTDSites.woa/60/wo +/SJ50004g800Ig400Xz/5.0.33.13.0.1.0.0.0.CustomContentActiveImageDispl +ayComponent.0.0.0 http://www.ecologyfund.com/registry/ecology/03_donate.html?noheader=-1 http://www.ecologyfund.com/registry/ecology/donate_pol.html?noheader=- +1 http://www.ecologyfund.com/registry/ecology/05_donate.html?noheader=-1 http://www.ecologyfund.com/registry/ecology/07_donate.html?noheader=-1 http://www.ecologyfund.com/registry/ecology/04_donate.html?noheader=-1 http://www.ecologyfund.com/registry/ecology/01_donate.html?noheader=-1 http://www.ecologyfund.com/registry/ecology/08_donate.html?noheader=-1 http://www.ecologyfund.com/registry/ecology/02_donate.html?noheader=-1
As you can see I'm not really interested in any returned content, I just want to automate several button clicks (each URL is an action performed by a button press) and see that no error was encountered.

Some questions:

Any suggestions welcomed as I plan to use LWP more and want to go about it correctly and with as few headaches as possible. Thanks.

--Jim


In reply to Simple requests using LWP::UserAgent by jlongino

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.