如何在Mechanize中模拟javascript?
如何使用如何在Mechanize中模拟javascript?,javascript,perl,postback,mechanize,Javascript,Perl,Postback,Mechanize,如何使用perlMechanize运行此JavaScript function __doPostBack(eventTarget, eventArgument) { var theform; if (window.navigator.appName.toLowerCase().indexOf("microsoft") > -1) { theform = document.Form1; } else {
perl
Mechanize
运行此JavaScript
function __doPostBack(eventTarget, eventArgument) {
var theform;
if (window.navigator.appName.toLowerCase().indexOf("microsoft") > -1) {
theform = document.Form1;
}
else {
theform = document.forms["Form1"];
}
theform.__EVENTTARGET.value = eventTarget.split("$").join(":");
theform.__EVENTARGUMENT.value = eventArgument;
theform.submit();
}
使用maybe可能会有所帮助……这需要安装Firefox吗?因为它没有安装在我正在使用的服务器上。是的,它需要FF…:(还有Mozrepl插件。你的“解决方案”很好——只是它不是“运行”JS,只是模拟JS的功能;):)
$mech->form_name("Form1");
$mech->field("__EVENTTARGET", $eventTarget);
$mech->field("__EVENTARGUMENT", $eventArgument);
$mech->submit();