簡體   English   中英

通過單擊網頁上的按鈕來運行/執行CasperJS腳本

[英]Run/Execute CasperJS script by clicking a button on webpage

我有一個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.

我在Google網上論壇的帖子中找到了解決方案

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

通過在目錄服務器(/ html)中移動CasperJS和PhantomJS可執行文件來工作

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM