perl - 使用 WWW::Mechanize 模块在 Perl 中填写表单

标签 perl mechanize www-mechanize

我正在创建一个脚本,该脚本使用 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/

相关文章:

apache - mod_perl 错误返回 202 Apache2::Const::HTTP_ACCEPTED

perl - 使用 Perl 的密码保护 PPT 文件

ruby-on-rails - 处理不同类别的 404 错误

perl - 我们如何告诉 WWW::Mechanize::Firefox 不等待响应或回发?

perl - 使用 WWW::Mechanize,如何添加带下划线的小写标题?

javascript - Perl 单击按钮与 WWW::Mechanize

mysql - 在 Perl 中实现跨线程/进程队列

perl - 在 Perl 中声明包版本方法的优缺点是什么?

ruby - Mechanize cookie_jar 不保存 session token

html - Perl Mechanize 打印 HTML 表单名称