Search code examples
phpweb-scrapingphantomjscasperjs

CasperJS passing data back to PHP


CasperJS is being called by PHP using an exec() command. After CasperJS does its work such as retrieving parts of a webpage, how can the retrieved data be returned back to PHP?


Solution

  • You can redirect output from stdout to an array.

    On this page it says you can do:

    string exec ( string $command [, array &$output [, int &$return_var ]] )
    

    It goes on to say:

    If the output argument is present, then the specified array will be filled with every line of output from the command.

    So basically you can do exec('casperjs command here, $array_here);