On 19/01/2011 09:56, Sean Murphy wrote:
Hi all.
I am having a bad week. things are not working as they should. Grin.
Fix one problem ane another pops up.
I have been successful in logging into other sites using the
identity method when a loging pop-up appears. But as yet, I have not
been successful in using a loging form that is built into the web
page. I believe I am doing this correct. >
the purpose of the script is to check for new books and eventually
to do searches. Also to learn PWL.
When I use the post approach, I receive the below from the request
headers:
loging: 1
trying to log in
response: 302 Found
headers: Cache-Control: private
Date: Wed, 19 Jan 2011 04:39:17 GMT
Location: https://www.x.net/signin.aspx?
Server: Microsoft-IIS/6.0
Content-Length: 158
Content-Type: text/html; charset=utf-8
Client-Date: Wed, 19 Jan 2011 04:39:17 GMT
Client-Peer: 2.4.3.2:80
Client-Response-Num: 1
Set-Cookie: ASP.NET_SessionId=414y4avh4fon1c451juvates; path=/; HttpOnly
Set-Cookie: SkinID=1; domain=x.net; expires=Thu, 19-Jan-2012 04:39:17 GMT;
path=/
Title: Object moved
X-AspNet-Version: 2.0.50727
X-Powered-By: ASP.NET
I have removed the actual correct ip addresses and web site for
privacy reasons. the code I am using to log in is:
use strict;
use constant DEBUG => 0;
use warnings;
use LWP::UserAgent;
use HTML::TokeParser;
use URI;
use HTML::TreeBuilder 3;
my $web_page = 'http://www.x.net/c-60-my-books.aspx';
my $login_page = 'http://www.x.net/signin.aspx';
my $browser = LWP::UserAgent->new( );
# Simulation of browser tag.
#$browser->agent("Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.5; .NET
CLR 2.0.50727; ffco7) Gecko/2008120122 Firefox/3.0.5");
# create an empty cooky jar.
$browser->cookie_jar( {} );
my $username_label = "EMail"; # email label.
my $password_label = "txtPassword";
my $user_id = 'name';
my $password = 'x';
my $response; # stores the response object.
print "trying to log in\n";
$response = $browser->post(
$login_page,
[
$username_label => $user_id,
$password_label => $password,
'LoginButton' => 'Login'
]);
my $text = $response->status_line( );
print "response: $text \n";
my $headers = $response->headers_as_string( );
print "headers: $headers\n";
my $content = $response->content( );
Any clues on what is not working, would be welcomed. is it possible to login
via the:
$browser->identity ( )
approach?
Hi Sean
If you look at the site's login page, you will see that
http://www.x.net/signin.aspx is redirected to a secure HTTPS page before
it accepts input. To handle this you will need Crypt::SSLeay installed
and used in your program.
Also there is a total of eight input fields to the form, and while you
may get away with leaving out some of them there are two hidden fields -
__VIEWSTATE and __EVENTVALIDATION - which are almost certainly necessary
to get past the login security that the site imposes. This is much more
easily handled using HTML::Form to copy the values of these hidden
fields to the login request.
HTH,
Rob
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/