簡體   English   中英

使用WWW :: Mechanize模塊在Perl中填寫表單

[英]Filling out form in Perl with the WWW::Mechanize module

我正在創建一個腳本,使用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();

上面是代碼,輸入中的所有值都是名稱,但它始終在同一行上出錯。

有問題的錯誤是button前缺少逗號。

使用use strict; use warnings; 他們會幫助你。

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();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM