简体   繁体   中英

How to run casperJS script from php API

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()函数,如下所示

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

您可以使用PHP-casperjs库这是一个简单的包装casperjs

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM