0
#!/usr/bin/perl -w
use WWW::Mechanize

$adres = qq{http://debian.ds/};
$mech = WWW::Mechanize->new();
$mech->get( $adres );
$mech->click( 'agreed' );
print $mech->content;
#

そして、次のように表示されます: /usr/local/share/perl/5.14.2/WWW/Mechanize.pm 行 1707 で合意された名前のクリック可能な入力はありません。

Html は次のようになります。

<fieldset class="submit-buttons">
<input type="submit" name="agreed" id="agreed" value="text1" class="button1" />&nbsp;
<input type="submit" name="not_agreed" value="text2" class="button2" />
<input type="hidden" name="change_lang" value="" />
<input type="hidden" name="creation_time" value="1373067606" />
<input type="hidden" name="form_token" value="83ab2ec47bc4ee37f" />
</fieldset>
4

2 に答える 2

2

最初に使用するフォームを選択する必要があると思います。

WWW::Mechanize の CPAN から

$mech->forms

Lists all the forms on the current page. Each form is an HTML::Form object. In list    context, returns a list of all forms. In scalar context, returns an array reference of all   forms.

$mech->form_number($number)

Selects the numberth form on the page as the target for subsequent calls to "field()" and   "click()". Also returns the form that was selected.

If it is found, the form is returned as an HTML::Form object and set internally for later      use with Mech's form methods such as "field()" and "click()".

Emits a warning and returns undef if no form is found.

The first form is number 1, not zero.
于 2013-07-06T00:21:34.387 に答える
0
my $mech = WWW::Mechanize->new;
$mech->get('file:///tmp/so17498270.html');
$mech->submit_form(
    with_fields => {
        agreed => 'text1',
    }
);
于 2013-07-07T12:42:36.753 に答える