1

我有一个 casperJS 脚本,它在命令行上运行时返回一个 JSON。我希望有这样的安排:1)我创建一个网页 2)单击网页上的按钮时,casperJS 脚本在服务器端执行并将结果发布/返回到网页。

我怎么能这样做。

编辑:我在单击按钮时调用用 php 编写的 AJAX 进程。php脚本包含 echo exec('casperjs sample.js');
它除了检查网络服务器错误日志之外什么也没返回,我得到了错误
'casperjs' is not recognized as an internal or external command, operable program or batch file.

PS:它通过命令行运行得非常好。

EDIT2
我将 php 脚本更改为:
echo exec('C:\casperjs\batchbin\casperjs .\sample.js');
错误已修改为:
'phantonjs' is not recognized as an internal or external command, operable program or batch file.

4

1 回答 1

1

我从我在 google group 上的帖子中找到了解决方案

https://groups.google.com/forum/#!topic/casperjs/7Lps6TiX-78

它通过在目录服务器 (/html) 中移动 CasperJS 和 PhantomJS 可执行文件来工作

于 2013-08-20T10:19:32.320 回答