mak has asked for the wisdom of the Perl Monks concerning the following question:
use HTTP::Cookies; use HTML::Form; use LWP; use URI; require 'dumpvar.pl'; my $LOGIN = ''; # put your login name here my $PASSWD = '';# password here my $ua = LWP::UserAgent->new(); # Step 1 $ua->agent('Mozilla'); # habit my $url = 'http://www.genesisreports.com/genesis/user/login.asp'; # St +ep 2 my $login_req = HTTP::Request->new(GET => $url); # Step 2 my $login_res = $ua->request($login_req); # Step 3 my $html = $login_res->content; my $form = HTML::Form->parse($html,'http://www.genesisreports.com/gene +sis/user/login.asp'); # Step 4 dumpValue(\$form); # Step 5 $form->value('artist',$LOGIN); # Step 6 $form->value('albumcode',$PASSWD); # Step 6 my $req = $form->click; # Step 7 print "11\n"; my $res = $ua->request($req); # Step 8 print "22\n"; my $cookie_jar = HTTP::Cookies->new(); # Step 9 $cookie_jar->extract_cookies($res); # Step 9 print "33\n"; my $goto = $res->header('location'); # Step 10 print "44\n"; my $new_req = HTTP::Request->new(GET => $goto); # Step 11 print "55\n"; $cookie_jar->add_cookie_header($new_req); # Step 12 print "66\n"; my $new_res = $ua->request($new_req); # Step 13 print "77\n"; # All done or you could keep going. # Parse this page for forms, URL's, or data # and have fun:) print $new_res->headers_as_string,"\n\n"; print $new_res->content,"\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Form Parsing / Cookie setup Error
by arturo (Vicar) on May 17, 2001 at 20:25 UTC |