SamCG has asked for the wisdom of the Perl Monks concerning the following question:
Here are my errors. Notice I changed to use the form number instead of the name on discovering that didn't work. Commenting out the submit, I still get a status of 401 -- Unauthorized, though I'm just trying to get the base page.#! perl -w use strict; use WWW::Mechanize; my $url = 'http://crnprdweb/CRN/cgi-bin/cognos.cgi?b_action=xts.run&m= +portal/main.xts'; my $mech = WWW::Mechanize->new(); $mech->get( $url ); print $mech->status, "\n"; print $mech->success; my $content = $mech->content; $mech->submit_form( form_number =>1, fields => { CAMUsername => 'blahuser', CAMPassword => 'blahpassword', } ); $content = $mech->content; print $content;
I'm wondering if this is specific to Cognos, and whether I should try automating IE instead. HTML and javascript isn't exactly my strength (I can scratch out a simple page of html, but I don't work with it extensively), so I've considered that it may be the nature of the submit button as well (though WWW::Mechanize indicates its "submit" function doesn't actually rely on the button, it's not clear to me what it does rely on). So, here's the code for that button (sans the actual function code).H:\script>perl mechtest.pl 401 There is no form named "pform" at mechtest.pl line 12 Can't call method "value" on an undefined value at C:/Perl/site/lib/WW +W/Mechaniz e.pm line 571. H:\script>perl mechtest.pl 401 There is no form numbered 1 at mechtest.pl line 12 Can't call method "value" on an undefined value at C:/Perl/site/lib/WW +W/Mechaniz e.pm line 571.
Can anyone give me some advice on how to get around these errors, or whether I'd be better advised to automate the browser instead of using Mech? Obviously I haven't gotten very far yet, and don't know what other errors I might encounter.<a href="javascript:doSubmit()" onblur="javascript:setFocus('')" onfoc +us="javascript:setFocus('ok')" onmouseover="window.status='';return t +rue;" onmouseout="window.status='';return true;"><span class="command +ButtonActive">OK</span></a>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: WWW::Mechanize Cognos web
by monarch (Priest) on Feb 02, 2006 at 00:37 UTC |