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.

In reply to 405 error when trying to log in by dannoura

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.