#!/usr/bin/perl -w use strict; use LWP::UserAgent; use WWW::Mechanize; use HTTP::Cookies; use HTTP::Request::Common qw(POST); #use LWP::Debug qw(+); my $user_name = '...'; my $encoded_pw = urldecode('...'); my $encoded_pw_unicode = urldecode('...'); my $base_url = 'https://courses.northwestern.edu/webapps/login/'; my $target_url = '...'; my $agent = WWW::Mechanize->new( autocheck => 1 ); $agent->cookie_jar(HTTP::Cookies->new); #Get the page once to get the initial cookies and store them #in the cookie jar $agent->get($base_url); die $agent->response->status_line unless $agent->success; my $req = POST $base_url, [ user_id => $user_name, encoded_pw => $encoded_pw, encoded_pw_unicode => $encoded_pw_unicode]; #This POSTs the form and also gets the new cookies and #stores them in the cookie jar $agent->request($req); die $agent->response->status_line unless $agent->success; #Get the desired page my $res = $agent->get($target_url); die $agent->response->status_line unless $agent->success; print $agent->content(); ...
In reply to Re^4: How to login to a form which has Javascript OnSubmit method usirng Perl
by ragas
in thread How to login to a form which has Javascript OnSubmit method usirng Perl
by ragas
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |