Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

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 = 'http://www.google.com/images/firefox/google.gif'; my $mech = WWW::Mechanize->new(); $mech->get( $url ); open (OUT, ">$local_image"); binmode OUT; # Windows only print OUT $mech->content;


-silent11
Spread Firefox


Comment on Re^3: save image on web
Download Code
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 <http://www.linpro.no/lwp/libwww-perl/README.SSL>.

    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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://416457]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2014-07-12 15:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (240 votes), past polls