【问题标题】:How to emulate javascript in Mechanize?如何在 Mechanize 中模拟 javascript?
【发布时间】:2016-03-11 01:10:43
【问题描述】:

如何使用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();
    }

【问题讨论】:

  • 使用metacpan.org/pod/… 可能会有所帮助....
  • 是否需要安装 Firefox?因为它没有安装在我正在处理的服务器上。
  • 是的,它需要 FF... :( 还有 Mozrepl 插件。

标签: javascript perl postback mechanize


【解决方案1】:
$mech->form_name("Form1");
$mech->field("__EVENTTARGET", $eventTarget);
$mech->field("__EVENTARGUMENT", $eventArgument);
$mech->submit();

【讨论】:

  • 你的“解决方案”很好——只是它不是“运行” JS,只是模拟 JS 所做的事情;):)
猜你喜欢
  • 2016-05-04
  • 1970-01-01
  • 2020-11-24
  • 1970-01-01
  • 1970-01-01
  • 2010-09-16
  • 2015-09-19
  • 2013-07-20
  • 2014-08-20
相关资源
最近更新 更多