如何从 php API 运行 casperJS 脚本 [英] How to run casperJS script from php API

查看:26
本文介绍了如何从 php API 运行 casperJS 脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 casperJS 脚本,它在通过命令行运行时返回 JSON.我想最好在 PHP 中创建一个 API,它在命令行(casperJS sample.js)中运行脚本并返回 JSON 作为结果.

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.

推荐答案

我认为你可以使用如下所示的 php exec() 函数来做到这一点

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

这篇关于如何从 php API 运行 casperJS 脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆