Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re^3: save image on web

by saskaqueer (Friar)
on Dec 21, 2004 at 05:51 UTC ( #416388=note: print w/ replies, xml ) Need Help??

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

In addition to NetWallah's suggestions, the site may also be blocking according to the referrer URL, or by the user-agent of the "browser", or possibly even by a cookie (if the image URL is that of a CGI script). Try this code (which is completely untested):

#!perl -w use strict; use LWP::UserAgent; use HTTP::Request::Common; my $url = ''; my ($referer) = $url =~ m!^(https?://[^/]+/)!; my $ua = LWP::UserAgent->new( agent => 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 4.0)', cookie_jar => {} ); # probably not needed, only needed if cookie is used # to test for "real browser". highly unlikely, but you # never know! $ua->get($referer); my $req = HTTP::Request->new( GET => $url ); $req->referer($referer); print $ua->request($req)->content();

Comment on Re^3: save image on web
Download Code
Replies are listed 'Best First'.
Re^4: save image on web
by kcella (Beadle) on Dec 21, 2004 at 12:32 UTC
    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://416388]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2015-11-30 04:09 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (757 votes), past polls