我有一个HTML表单,我想用WWW::Mechanize
模块处理。我似乎无法发布包含美元符号$
的输入值。我收到此运行时错误消息:
Can't call method "value" on an undefined value at script.pl line 599
我的脚本看起来像这样
my $agent = WWW::Mechanize->new( autocheck => 1, ssl_opts => { verify_hostname => 0 }, );
my $formfiller = WWW::Mechanize::FormFiller->new();
$agent->env_proxy();
$agent->get('https://site.com/form.php');
$agent->form_number(1) if $agent->forms and scalar @{$agent->forms};
$agent->form_number(1);
{
local $^W;
$agent->current_form->value('page_contentleft_0$form_D69D9E5239FC412ABB92A81D73F690AD$field_F40A1785D7B3490CBD5E72EDBE6B966D', 'John Doe');
}; #// First NAme
{
local $^W;
$agent->current_form->value('page_contentleft_0$form_D69D9E5239FC412ABB92A81D73F690AD$field_E3316C46A4404C73ACBAE107DF6206D2', 'Bridgeport');
}; #// City
{
local $^W;
$agent->current_form->value('page_contentleft_0$form_D69D9E5239FC412ABB92A81D73F690AD$field_E5747EB507E74DC1937557F9285CB57C', 'CT');
}; #// state
{
local $^W;
$agent->current_form->value('page_contentleft_0$form_D69D9E5239FC412ABB92A81D73F690AD$field_A612569BE44C4BA3AD0AB3FBF8FB0553', '06604');
}; #// Zipcode
$agent->submit(Submit);
据我所知,问题是从参数到value
方法,例如
page_contentleft_0$form_D69D9E5239FC412ABB92A81D73F690AD$field_A612569BE44C4BA3AD0AB3FBF8FB0553
如何让Perl通过$
,或以其他方式解决?
答案 0 :(得分:0)
你确定有吗?
$agent->submit(Submit);
请尝试使用此代码:
$agent->get('https://site.com/form.php');
$agent->submit_form(
with_fields => {
'page_contentleft_0$form_D69D9E5239FC412ABB92A81D73F690AD$field_F40A1785D7B3490CBD5E72EDBE6B966D' => 'John Doe',
'page_contentleft_0$form_D69D9E5239FC412ABB92A81D73F690AD$field_E3316C46A4404C73ACBAE107DF6206D2' => 'Bridgeport',
'page_contentleft_0$form_D69D9E5239FC412ABB92A81D73F690AD$field_E5747EB507E74DC1937557F9285CB57C' => 'CT',
'page_contentleft_0$form_D69D9E5239FC412ABB92A81D73F690AD$field_A612569BE44C4BA3AD0AB3FBF8FB0553' => '06604'},
button => "Submit",);