I am trying to login to a page programmatically using Perl. I am using the WWW::Mechanize module to get the content of a page, set the fields and submit the values. But since WWW::Mechanize does not support Javascript, the login process has been failing. I would like to know if there is any other way/workaround I could login to a page which does javascript validation of the field before POSTing.

Here is my program:
use strict; use LWP::UserAgent; use WWW::Mechanize; use HTTP::Cookies; use LWP::Debug qw(+); my $user_name = '...'; my $password = '...'; my $base_url = 'https://courses.northwestern.edu/webapps/login/'; my $agent = WWW::Mechanize->new( autocheck => 1 ); $agent->cookie_jar(HTTP::Cookies->new); $agent->get($base_url); die $agent->response->status_line unless $agent->success; #print $agent->content; $agent->set_fields( user_id => $user_name, password => $password ); #print $agent->content(); my $res = $agent->submit(); if ($res->is_success) { print $res->as_string; } else { print "Failed: ", $res->status_line, "\n"; }

And the HTML code contains:
<FORM ONSUBMIT="return validate_form(this)" METHOD="POST" ACTION="https://courses.northwestern.edu/webapps/login/" NAME="login" >

validate_form() is a Javascript method. Any help on this would be much appreciated.

Thanks in advance,
Ragas

In reply to How to login to a form which has Javascript OnSubmit method usirng Perl by ragas

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.