#!/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" />
<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>
最佳答案
我认为您需要先选择要使用的表格。
来自 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.
关于Perl Mechanize 提交按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17498270/