in reply to Re^2: Downloading PHP-generated images using the LWP::UserAgent and WWW::Mechanize modules
in thread Downloading PHP-generated images using the LWP::UserAgent and WWW::Mechanize modules

You need the full url for $ua->mirror(). If the urls in the HTML source are relative, your regex won't create a full url to mirror.

You should probably use WWW::Mechanize's find_image() or find_all_images() method:

for my $img ($www->find_all_images()) { $www->mirror($img->url_abs()); }
update: you probably also don't need both an LWP::UserAgent and a WWW::Mechanize object, since WWW::Mechanize is a subclass of LWP::UserAgent. In fact, chances are, it will work better with just one WWW::Mechanize object.

  • Comment on Re^3: Downloading PHP-generated images using the LWP::UserAgent and WWW::Mechanize modules
  • Download Code

Replies are listed 'Best First'.
Re^4: Downloading PHP-generated images using the LWP::UserAgent and WWW::Mechanize modules
by Anonymous Monk on Nov 27, 2009 at 05:34 UTC
    It dosen't work for this code.. #!C:/Perl/bin/perl.exe -w use warnings; use strict; use WWW::Mechanize; my $mech = WWW::Mechanize->new(agent => 'Mozilla/5.0'); $mech->mirror('http://www.click.in/includes/gd.php?scode=NzQwOTc0','d:/img.jpg'); Please replay me how to download this image.