【发布时间】:2018-04-16 04:30:39
【问题描述】:
我有那个表格
<form method="post" action="index.lp" name="authform" id="authform">
<input type="password" name="password" id="password" onkeypress="return enter_submit(event);" />
<input name="enter" class="btn btn-primary" type="button" value="log in" onclick='auth()' />
我可以通过这种方式提交,谢谢 javascript
javascript:document.getElementById("password").value = "password";auth();
现在我需要编写 perl 脚本来自动执行此操作,并在它登录时在页面中执行其他 javascript 函数。 我在电脑上测试,有问题:
1) Perl 需要一个 c 编译器...在我可以在 openwrt 上安装它之后?
2) 我可以尝试两种不同的方法:
第一个也是更快的是使用 WWW::Scripter::Plugin::JavaScript 但我无法安装模块,因为我无法安装 mingw(我在 ppm-shell 中安装了 mingw它返回“ppm 安装失败:找不到任何提供 mingw 的软件包”)。此外,我在Perl package 中看不到 WWW::Scripter。 我写了那个脚本(它可以工作吗?):
use WWW::Scripter;
$w = new WWW::Scripter;
$w->use_plugin('JavaScript');
$w->get('http://url');
$w->get('javascript:document.getElementById("password").value = "password";auth();');
sleep (1);
$w->get('http://url');
$w->get('javascript: function();');
第二个是使用WWW:Mechanize。我怎样才能看到输出页面?以及如何将命令发送到第二页?现在使用该脚本,我收到此错误:“D:/Program Files/Perl/lib/HTTP/Response.pm 第 92 行缺少基本参数。”。 (可以吗?)
use WWW::Mechanize;
my $mech = WWW::Mechanize->new();
$mech->get( $url );
$mech->follow_link( url => 'http://url' );
$mech->submit_form(
form_name => 'authform',
fields => { password => 'password', },
button => 'log in'
);
【问题讨论】:
标签: javascript perl openwrt www-mechanize