I created a small script to download all the images from any given HTML page. It works otherwise just fine, but some sites are using redirection to their index page unless the user arrives onto this page from their site (server reading the HTTP_REFERER).

I took this into consideration in my script after reading a bit more about this from Google. Below is a snippet of the script that fails and the error, too

$http = LWP::UserAgent -> new; $http->timeout(10); $http->agent("Mozilla/4.0 (compatible; MSIE 5.5; Windows 98)"); $http->header('Referer' => "$referer") if defined $referer; # send HTT +P_REFERER if requested $content = $http->get($src);
www:~/Documents/testStuff/getImagesFromWww mellimik$ perl getImagesFro +mWww.pl http://localhost/ total of 1 images Can't locate object method "header" via package "LWP::UserAgent" at ge +tImagesFromWww.pl line 86. www:~/Documents/testStuff/getImagesFromWww mellimik$

In reply to LWP::UserAgent and sending the HTTP_REFERER by mellin

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.