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");