Perl Mechanize 提交按钮

标签 perl web submit mechanize

#!/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>

最佳答案

我认为您需要先选择要使用的表格。

来自 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/

相关文章:

perl - $x->{a}{b} 和 $x->{a}->{b} 的区别

perl - 当数值比较为假时,Perl 返回什么?

ios - 移动ios上的背景图像模糊

windows - 在 Windows 8 中将 Web 应用程序显示为全屏应用程序

javascript - jQuery submit()、change() 和页面刷新

javascript - 为什么在 if 条件为 false 的情况下提交表单?

perl - Perl 数据结构的简单、现代、健壮、透明的持久性

perl - 如何用perl修改crontab?

r - r 中的网络抓取(带循环)

php - 这段代码中定义的表单的 `submit()` 函数在哪里?