RE: LWP with SSL and Client Side Cookies...
QUONIX WEB ADMIN <[email protected]>
| Newsgroups | gmane.comp.lang.perl.modules.lwp |
|---|---|
| Message-ID | <[email protected]> |
I've tried using cookie_jar but I cant seem to get it to work. Here is a
snippet of code that I am using. Its a little dirty, but it hits the
entrance page of the site, grabs the cookies. Where I am stuck is, on my
2nd http request, I need to take those cookies and insert them into the
header of the second request.
use LWP::UserAgent;
$ua = LWP::UserAgent->new(keep_alive => 1);
$ua->agent('Mozilla/5.0')
# Initial non-ssl request to homepage to grab cookies:
#
# JSESSIONID, serverName, and BIGipServerPROD-EXCHANGE-80
my $response_a = $ua->get("http://www.intervalworld.com");
# $response_a->header("set-cookie") now contains my three cookies
# which I can grab with regular expressions.
# Now I need to POST for login and insert those three cookies
# in the request header.
my %formdata = (
login => "abc123",
passwd => "xyz456",
);
# my $response_b = $ua->post("https://secure.intervalworld.com/web/cs", \%formdata )
# Here is where I am stuck, I dont know how to insert
# those previosly stored cookies. I've tried cookie_jar
# but it doesn't seem to work.
-irwin
On Tue, 25 Oct 2005 [email protected] wrote:
> [email protected] wrote:
> > The cookies are key to being able to get inside the site. I have never
> > done this with LWP, started playing around with cookie jar - but have
> > not had any luck.
>
> Here's a bit of my custom spider class's new($)...
>
> $self = LWP::RobotUA->new(
> agent => $_user_agent,
> from => $_from,
> requests_redirectable =>
> [ 'GET',
> 'HEAD',
> 'POST', # default is just GET and HEAD
> ],
> );
>
> # use cookies
> $self->cookie_jar(HTTP::Cookies->new());
>
> I don't need to save cookies from session to session... but if you do, there's a way to load a cookie jar from a file.
>
> --
> Matthew.van.Eerde (at) hbinc.com 805.964.4554 x902
> Hispanic Business Inc./HireDiversity.com Software Engineer
>
>