WWW::Mechanize, save images from a page

"Dhanashri Bhate" <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.lwp
Organization Persistent Systems
Message-ID <[email protected]>
Hi All,

I am currently automating some UI tests with the help of WWW::Mechanize
module.

I need to save images on a webpage.

 

I tried using the find_image function to get the reference of the image ( as
shown in the script below ).

But do not understand how I can save that image in a file.

 

Kindly help!

 

-------------------------------------

My program:

-------------------------------------

#!/usr/local/bin/perl

 

use strict;

use warnings;

use WWW::Mechanize;

 

my $mech = WWW::Mechanize->new();

$mech->quiet(0);                #turn on warnings

 

my $host = "abc.xyz.com";

my $url = "http://$host/email";

$mech->get($url);

 

my $imageref = $mech->find_image( url_regex => qr/gen_login_logo/ );

if ( $mech->success )

{

    print "Found the image, reference is : $imageref\n";

}

else

{

    print "Did not find the image\n";

}

 

 

------------------------------------ 

The Output:

------------------------------------

-bash-2.05b$ ./save_images.pl

Found the image, reference is : WWW::Mechanize::Image=HASH(0x850d024)

 

 

 

Thanks,

Dhanashri
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.