Answer the question
In order to leave comments, you need to log in
Why can't I run casperjs from php?
The second day I'm scratching my head, please help me figure it out. The task is to run casperjs not through the console, but through a php script. What I've done? I copied the phantomjs, casperjs and python downloaded from the official sites to the C drive, registered the path C: / casperjs / bin; C: / phantomjs / bin; C /: Python27 in the Path variable, separated by a semicolon. I initiated git in the project folder and checked the versions of casperjs and phantomjs in its console, everything shows fine. Moreover, I can run a test file for Casper, it works and even gives screenshots from the screen.
But I'm stuck on the problem of how to run Casper from a php file ... it just doesn't show anything. Here are my files
error_reporting(E_ALL);
$start = microtime(true);
echo date("H:i:s");
function parser() {
try {
putenv("PHANTOMJS_EXECUTABLE=/usr/local/bin/phantomjs");
putenv("DYLD_LIBRARY_PATH");
echo(shell_exec('casperjs test.js '));
flush();
} catch (Exception $exc) {
echo('Error!');
echo $exc->getTraceAsString();
}
}
parser();
//////////////////////////////////////////////////////////////////////////
$time = microtime(true) - $start;
printf("<br>".date('H:i:s').' Готово! Процесс выполнялся %.4F сек.', $time);
var casper = require('casper').create();
casper.start('http://casperjs.org/', function() {
this.echo(this.getTitle());
});
casper.thenOpen('http://phantomjs.org', function() {
this.echo(this.getTitle());
});
casper.run();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question