4

mechanize モジュールを使用して Perl で Web フォームにログインするスクリプトを作成していますが、次のエラーが発生します。

/home/arty/scripts/gmail_pw_chngr.pl の 18 行目の "button" 付近の構文エラー コンパイル エラーのため、/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();

上記のコードは、入力からのすべての値が名前ですが、常に同じ行でエラーになります。

4

3 に答える 3

7

問題のエラーは、 の前にカンマがないことbuttonです。

于 2012-12-09T05:27:04.840 に答える
3

とを使用use strict;use warnings;ます。彼らはあなたを助けるでしょう。

于 2012-12-09T13:39:44.373 に答える
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();
于 2012-12-09T14:10:00.017 に答える