dannoura has asked for the wisdom of the Perl Monks concerning the following question:
hi,
I'm trying to automate my login to this site. It's encrypted, but I have OpenSSL, so that should be no problem. But, I keep getting 405 Method not allowed when using the code:
#! c:\perl\bin -w use strict; use LWP::UserAgent; use LWP::Protocol::https; use HTTP::Request::Common; my $ua = LWP::UserAgent->new; my $request = POST 'https://www.saxobank.com/', [ UserID => 'myID', Password => 'myPasswd', ]; my $page = $ua->request($request); if ($page->is_success) { print $page->content; } else { print $page->status_line; }
And the same when using the code:
#! c:\perl\bin -w use strict; use LWP::UserAgent; use LWP::Protocol::https; use HTTP::Request::Common; use HTTP::Cookies; # form variables my $UserID = 'myID'; my $password = 'myPasswd'; # bot variables my $agent = LWP::UserAgent->new; my $cookie_jar = HTTP::Cookies->new; my $res; # URL's of importance my $login_url = 'https://www.saxobank.com'; &login($agent, $res, $cookie_jar, $UserID, $password, $login_url); exit; sub login($$$) { my( $agent, $res, $cookie_jar, $UserID, $password, $login_url) = @_; # build request for login web page (so we get the set of cookies) my $req = POST ($login_url, [ cmd => 'login', dest => 'https://www.saxobank.com', UserID => $UserID, Password => $password, ]); # issue the request $res = $agent->request($req); if ($res->is_success) { print $res->content; } else { print $res->status_line, "\n"; } # extract the cookies $cookie_jar->extract_cookies($res); }
Any ideas about how to tackle this problem?
-----------------------------------
Any comments about coding style are welcome.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: 405 error when trying to log in
by rob_au (Abbot) on Apr 28, 2004 at 13:55 UTC | |
by dannoura (Pilgrim) on Apr 28, 2004 at 14:34 UTC | |
by PodMaster (Abbot) on Apr 28, 2004 at 21:47 UTC | |
Re: 405 error when trying to log in
by EdwardG (Vicar) on Apr 28, 2004 at 13:54 UTC | |
by dannoura (Pilgrim) on Apr 28, 2004 at 14:36 UTC | |
by PodMaster (Abbot) on Apr 28, 2004 at 21:42 UTC |
Back to
Seekers of Perl Wisdom