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.