It could be that the server in question started checking for the user agent type of all incoming requests, and rejecting those corresponding to the $ua object of LWP::Simple. To test this hypothesis, add the following line somewhere after the definition of my $ua, but before calling LWP::Simple::get:

$LWP::Simple::ua->agent( $ua->agent );
The idea is to make the agent field LWP::Simple's internal user agent object (which is also called $ua) match the corresponding default agent field for a LWP::UserAgent object (like your $ua).

Update: I should have pointed out in my original post that if the hypothesis above is correct, this would strongly suggests that the site you are trying to access has an anti-robot policy. The workaround implied by the code above is a technical solution, but it is up to you to determine what the site's robot policy is (starting with reading their robots.txt file, if any), and weigh the consequences of circunventing it. Some site's are very strict and unequivocal about this.

Update 2: As indicated by the overstrike above, the particular details of what I proposed were wrong, because importing $ua from LWP::Simple has side-effects that don't take place if one omits the import step and uses the fully qualified $LWP::Simple::us, which I was not aware of (thanks++ to dpmott for pointing it out).

the lowliest monk


In reply to Re: Why would LWP::Simple::get stop working? by tlm
in thread Why would LWP::Simple::get stop working? by dpmott

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.