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

前端之家收集整理的这篇文章主要介绍了使用WWW :: Mechanize模块在Perl中填写表单前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在创建一个脚本,使用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();

上面是代码,输入中的所有值都是名称,但它始终在同一行上出错.

解决方法

有问题的错误是按钮前缺少逗号.

猜你在找的Perl相关文章