fightliteracy has asked for the wisdom of the Perl Monks concerning the following question:

I need to get a lot of images from a web server by examining the webpage for image url, then fetching the image. the problem is that the server requires username and password authentication and not just basic http authentication. they have some script that sets a bunch of cookies. right now i am doing this by so (and I have already tried Image::Grab to no avail)
$req = new HTTP::Request 'GET',"http://ftp.website.com/download.asp?f= +/image.gif $req->push_header(cookie=>"ID=b9a15e1"); $req->push_header(cookie=>"SESSION=LLMODEMBGI"); my $ua = new LWP::UserAgent; $rc = $ua->request($req); my $image = $rc->content;
but their server doesn't seem to recognize the cookies being sent, even though that is the same data being used by netscape/IE/Opera etc, etc. thus i am unable to get the image.
----
FightLiteracy
http://www.fightliteracy.com

Replies are listed 'Best First'.
Re: Get an image off a server and send cookies
by merlyn (Sage) on Oct 16, 2001 at 05:10 UTC
    Why not just use a cookie jar, go to the login screen with your virtual browser, accept the cookies, and save them into a jar? Then visit the page you want with a virtual browser that uses that same cookie jar?

    We've discussed cookie jars here before, so the Super Search should be your friend.

    -- Randal L. Schwartz, Perl hacker

Re: Get an image off a server and send cookies
by cacharbe (Curate) on Oct 16, 2001 at 05:21 UTC
    What merlyn said.

    I was kind enough to even write a node discussing almost exactly what you are looking for here.

    Of course you can just forget the basic Authentication piece, and post the info to their login script.

    C-.