How to run casperJS script from php API

杀马特。学长 韩版系。学妹 提交于 2019-12-01 09:00:07

问题


I have a casperJS script which returns JSON when run via commandline. I want to make an API preferably in PHP which runs the script as in commandline (casperJS sample.js) and returns the JSON as result.


回答1:


You can use php-casperjs library which is a simple wrapper for casperjs.




回答2:


I think you can use php exec() function as shown below to do this

echo exec("/home/user/casperjs/bin/casperjs /full/path/to/your_script.js");


来源:https://stackoverflow.com/questions/18302267/how-to-run-casperjs-script-from-php-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!