Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re^3: save image on web

by silent11 (Vicar)
on Dec 21, 2004 at 13:33 UTC ( #416457=note: print w/replies, xml ) Need Help??

in reply to Re^2: save image on web
in thread save image on web

You never gave us the actual URL of the image you are trying to download so we are leading you blindly. This script works for me.
use strict; use WWW::Mechanize; my $local_image = './google.gif'; my $url = ''; my $mech = WWW::Mechanize->new(); $mech->get( $url ); open (OUT, ">$local_image"); binmode OUT; # Windows only print OUT $mech->content;

Spread Firefox

Replies are listed 'Best First'.
Re^4: save image on web
by kcella (Beadle) on Dec 22, 2004 at 00:51 UTC
    I tried WWW::Mechanize and it gave me a blank image. There is something in the web server daemon that is preventing me from downloading through a request/response. I can only save off the image if I do it manually. I was able to save the image by using a hack solution with Win32::GuiTest. The module allows me to automate key presses as if I were typing them.
    use Win32::GuiTest qw(SendKeys); $IE->Navigate( $url ); <wait> SendKeys("%f$path~");
    I wish to revisit the OLE automation and ExecWB command. I don't understand why this does not work. The following snippet should work, but it never saves the image unless I show the dialog and select the path manually.
    $IE->Navigate( $url ); while( $IE->{Busy} ) { while($IE->SpinMessageLoop()) { select undef, undef, undef, 0.25; } } $var = Variant( VT_BSTR, "./image.jpg" ); # 4 = SAVE_AS; 3 = HIDE_DIALOG $IE->ExecWB( 4,3,$var,undef );
    PS: For some reason I can't see my last post, so here it is again:

    Got the following message when trying to run saskaqueer's code:

    LWP will support https URLs if the Crypt::SSLeay module is installed. More information at <>.

    I tried installing Crypt::SSLeay, but ppm3 does not have a win32 version. As for NetWallah's suggestions, I have a direct URL to the image, so it is not in a frame. It is also under 4 MB, not generated by javascript and not beign re-directed. I can download it manually just fine. I would post the URL, but it would not help since it is part of a password protected site and it would just redirect you to a login.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://416457]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (10)
As of 2018-06-19 10:40 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (113 votes). Check out past polls.