我正在创建一个脚本,该脚本使用 mechanize 模块在 Perl 中登录 Web 表单,但出现错误:
syntax error at /home/arty/scripts/gmail_pw_chngr.pl line 18, near "button" Execution of /home/arty/scripts/gmail_pw_chngr.pl aborted due to compilation errors.
代码
use WWW::Mechanize;
my $mech = WWW::Mechanize->new();
my $url = "https://accounts.google.com/Login";
$mech->get($url);
$result = $mech->submit_form(
form_name => 'gaia_loginform', # Name of the form
#Instead of form name you can specify
#form_number => 1
fields =>
{
Email => 'arty32l@gmail.com', # Name of the input field and value
Passwd => 'password',
}
button => 'signIn' # Name of the submit button
);
print $result->content();
上面是代码,输入中的所有值都是名称,但它总是在同一行出错。
最佳答案
有问题的错误是 button
之前缺少逗号.
关于perl - 使用 WWW::Mechanize 模块在 Perl 中填写表单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13784915/