Perl机械化脚本没有定义形式

时间:2013-06-14 00:02:59

标签: forms perl post mechanize

我收到错误No form defined at cqSubmitter.pl at line 33这是第二个set_fields方法。其他时候我会收到Error POSTing http://micron.com Internal Server Error at line 39,这与最后click_button行相对应。

我不确定发生了什么,为什么说没有定义任何形式?包含第一个click_button方法的代码的前半部分工作正常并保存了正确的页面,但是当我第二次尝试set_fields时,它会出错。

任何熟悉Mechanize包的人都会意识到这里发生了什么?

use Data::Dumper;
use HTTP::Request::Common qw(GET);
use WWW::Mechanize;


#Prepopulated information
my $types_ = "";
my $dept_ = "";
my $group_ = "";


#Create new WWW::Mechanize object
my $mech = WWW::Mechanize->new( 'ssl_opts' => { 'verify_hostname' => 0 } );
my $url = "http://f2prbrequest";

#Fetch URL or Die Tryin'
$mech ->get($url);

$fname = "user";
$pswd = "password";


#Login to ClearQuest form using credentials
$mech->set_fields(
    USER => $fname
   ,PASSWORD => $pswd
);


$mech->click_button(
   name => 'Submit'
 );


#Set fields and actually fill out ClearQuest Form
$mech->set_fields(
    types => $types_
   ,dept => $dept_
   ,group => $group_
  );


$mech->click_button(
    name => 'submit1'
 );

$mech->save_content("clearQuestFilled.html");

0 个答案:

没有答案