How to run casperJS script from php API

I have a casperJS script that returns JSON when run through the command line. I want to make the API preferably in PHP, which runs the script as on the command line (casperJS sample.js), and returns the JSON result.

+2
source share
2 answers

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

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

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

+3
source

All Articles