in reply to LWP and Site Logins
An underused trick is to use LWP::Debug in your script. This will give you some indication as to what is going on during the request/response process.
As you've noted, your script returns a 302 header, which is a redirect. LWP::UserAgent will automatically follow redirects on GET and HEAD requests. Adding POST to that list will get you to the proper page.
Assuming you've entered a proper username and password you'll move on, other wise you'll be back at the login page.
use strict; use warnings; use HTTP::Cookies; use LWP::UserAgent; use LWP::Debug qw( + ); my $url = 'https://noii.nasdaqtrader.com/'; my $agent = LWP::UserAgent->new( cookie_jar => HTTP::Cookies->new, requests_redirectable => [ 'GET', 'HEAD', 'POST' ] ); my $response = $agent->post( $url, { txtUserName => '***', txtUserPass => '***' } ); print $response->content;
--
"Go up to the next female stranger you see and tell her that her "body is a wonderland."
My hypothesis is that she’ll be too busy laughing at you to even bother slapping you." (src)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: LWP and Site Logins
by shagbark (Acolyte) on Jul 01, 2007 at 04:39 UTC | |
by LTjake (Prior) on Jul 01, 2007 at 14:18 UTC |