Forum Moderators: coopster & phranque

Message Too Old, No Replies

accessing authorized pages via lwp

how does it work?

         

yerman

4:03 pm on Mar 12, 2005 (gmt 0)

10+ Year Member



Hi everyone!
I've developed a little perl program using the module LWP to download italian stock pages, to make real time statistics.
The program downloads delayed pages, but it doesn't download real time pages because of the
authentication.
I mean the authentication is made at session level, so I need to authenticate in some way in the same program.
I've tried to use $ua->credentials
and $req->authorization_basic, but without results.
I confess I'm novice in perl programming and in using LWP, and surely it's my fault.
Can anyone help me?

My simple code is:

$protected_page="http://www.example.com/fc?sezId=10026&cmd=miafinanza&page=ListinoPersonale";

use LWP::UserAgent;
$ua = LWP::UserAgent->new;

#
# Authentication block?
#

$req = HTTP::Request->new(GET => "<$protected_page>");

$res = $ua->request($req);
if ($res->is_success)
{
$out="c:/mypage.txt";
open OUT, ">$out" or die "Cannot open $out for write :$!";
print OUT $res->content;
close OUT;
}
else
{
print "Time out: fault in download \n";
}

I thank you in advance for whatever help you can give me.

[edited by: jatar_k at 5:22 pm (utc) on Mar. 12, 2005]
[edit reason] generalized url [/edit]

Moby_Dim

6:02 pm on Mar 12, 2005 (gmt 0)

10+ Year Member



What about cookies there?

Isn't Mechanize more suitable in this case?

yerman

8:05 am on Mar 13, 2005 (gmt 0)

10+ Year Member



Yes, probably it's a way.
I've seen connecting to the url leaves different cookies on my pc for every different session (as you can see with those credentials).
Do you know how to manage those cookies inside the program, so to appear as a logged user?
I've tried, but probably something goes wrong...

Thank you for your interest, any practical suggestions would be very precious.

Moby_Dim

9:07 am on Mar 13, 2005 (gmt 0)

10+ Year Member



Each case is different. Read Burke's ch.11 to catch the idea.