Hi,

It looks like I am stuck with form parsing. I tackeled down one problem with artura's help. Now I got another one. HTML::form does not seem to parse multiple forms in a html file. The page that I need to login has two forms and it only gets the first one, which isn't the one I want. How would I get all the form in a HTML file? Any suggestions?

Mak

use HTTP::Cookies; use HTML::Form; use LWP; use URI; require 'dumpvar.pl'; my $LOGIN = 'lillyglobal'; # put your login name here my $PASSWD = 'analysis';# password here my $ua = LWP::UserAgent->new(); # Step 1 $ua->agent('Mozilla'); # habit my $url = 'http://www.datamonitor.com/login.asp'; # Step 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.datamonitor.com/login.a +sp'); # Step 4 dumpValue(\$form); # Step 5 $form->value('un',$LOGIN); # Step 6 $form->value('pw',$PASSWD); # Step 6 my $req = $form->click; # Step 7 my $res = $ua->request($req); # Step 8 my $cookie_jar = HTTP::Cookies->new(); # Step 9 $cookie_jar->extract_cookies($res); # Step 9 my $goto = $res->header('location'); # Step 10 my $new_req = HTTP::Request->new(GET => 'http://www.datamonitor.com/se +cure/listaccpurchases.asp') or die "Can't get $goto: $!\n";; # Step 11 $cookie_jar->add_cookie_header($new_req); # Step 12 my $new_res = $ua->request($new_req); # Step 13 print $new_res->headers_as_string,"\n\n"; open (FH, ">D:\\Mustafa\\Perl\\Code\\dm.html") || die "Can't open file to write\n"; print FH $new_res->content; #if ($new_res->is_success); print $new_res->content,"\n";

In reply to Can not get all the form elements by mak

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.