我正在使用mechanize模块创建一个在Perl中登录到Web表单的脚本,我收到错误:
/home/arty/scripts/gmail_pw_chngr.pl第18行的语法错误,靠近“按钮” /home/arty/scripts/gmail_pw_chngr.pl的执行因编译错误而中止。
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();
上面是代码,输入中的所有值都是名称,但它总是在同一行上出错。
答案 0 :(得分:7)
有问题的错误是button
之前缺少的逗号。
答案 1 :(得分:3)
使用use strict;
和use warnings;
。他们会帮助你。
答案 2 :(得分:0)
use CGI qw(:standard);
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
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();