hi,

I'm trying to login to a this site, which uses https. Problem is, I get an internal server error. Here's my code:

#! c:\perl\bin -w use strict; use LWP::UserAgent; use HTTP::Request::Common; use HTTP::Cookies; use LWP::Debug qw(+); use LWP::Protocol::https; use crypt::SSLeay; my $ua = LWP::UserAgent->new; $ua->cookie_jar(HTTP::Cookies->new(file => 'cookie_jar', autosave =>1) +); # configure LWP::UserAgent to follow redirects after POST push @{ $ua->requests_redirectable }, 'POST'; my $request=$ua->request(POST "http://www.saxobank.com/", { username =>'me', userpass =>'secret', submit =>'Submit' }); print $request->is_success ? $request->content : "failed\n";

The output from LWP::Debug is:

LWP::UserAgent::new: () LWP::UserAgent::request: () HTTP::Cookies::add_cookie_header: Checking www.saxobank.com for cookie +s HTTP::Cookies::add_cookie_header: Checking .saxobank.com for cookies HTTP::Cookies::add_cookie_header: Checking saxobank.com for cookies HTTP::Cookies::add_cookie_header: Checking .com for cookies LWP::UserAgent::send_request: POST http://www.saxobank.com/ LWP::UserAgent::_need_proxy: Not proxied LWP::Protocol::http::request: () LWP::UserAgent::request: Simple response: Internal Server Error

Any ideas?

Update:Using the above code with the URL https://www.saxobank.com/Default.aspx?ID=867 gives the response:

LWP::UserAgent::new: () LWP::UserAgent::request: () HTTP::Cookies::add_cookie_header: Checking www.saxobank.com for cookie +s HTTP::Cookies::add_cookie_header: Checking .saxobank.com for cookies HTTP::Cookies::add_cookie_header: Checking saxobank.com for cookies HTTP::Cookies::add_cookie_header: Checking .com for cookies LWP::UserAgent::send_request: POST https://www.saxobank.com/Default.as +px?ID=867 LWP::UserAgent::_need_proxy: Not proxied LWP::Protocol::http::request: () LWP::Protocol::collect: read 47 bytes LWP::Protocol::collect: read 100 bytes HTTP::Cookies::extract_cookies: Set cookie ASP.NET_SessionId => 3v0qpi +550pgfofqpbbv3qc45 LWP::UserAgent::request: Simple response: Found LWP::UserAgent::request: () HTTP::Cookies::add_cookie_header: Checking www.saxobank.com for cookie +s HTTP::Cookies::add_cookie_header: - checking cookie path=/ HTTP::Cookies::add_cookie_header: - checking cookie ASP.NET_SessionId +=3v0qpi550pgfofqpbbv3qc45 HTTP::Cookies::add_cookie_header: it's a match HTTP::Cookies::add_cookie_header: Checking .saxobank.com for cookies HTTP::Cookies::add_cookie_header: Checking saxobank.com for cookies HTTP::Cookies::add_cookie_header: Checking .com for cookies LWP::UserAgent::send_request: POST http://www.saxobank.com?ID=867 LWP::UserAgent::_need_proxy: Not proxied LWP::Protocol::http::request: () LWP::UserAgent::request: Simple response: Internal Server Error

Which leads me to believe (because two requests were sent, with only the second one being unsuccessful) that a redirection is supposed to occur, but which LWP does not follow, despite the line specifically instructing it to do so. No solution as yet...


In reply to logging in to secure site 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.