user2129794
user2129794

Reputation: 2418

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.

Upvotes: 2

Views: 2746

Answers (2)

SG_
SG_

Reputation: 1336

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

Upvotes: 3

Ravi Misra
Ravi Misra

Reputation: 191

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

Upvotes: 3

Related Questions