-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can not find CasperJS #25
Comments
hello, it seems that Casper class is not finding your local casperjs installation or your temp dir is not configured correctly. $casper = new Casper('C:\\your-path-to-casperjs', 'C:\\your-temp-dir'); If it is still not working, can you check the file created in your temp directory, you should be able to run it this way:
|
Thanks, what is the temp directory you are referring to? |
The temp directory is the directory where the plain javascript casperjs files are created during the session. The script is created during |
Hello Alwex Thanks |
Hello nikhilsuccessive, Check if casperjs executable is available in the path of the user that will execute the php code. |
@alwex Thanks for replying fast.Now its upto you please save my job. when i am running on server it showing this error "Can not find CasperJS in path: /usr/bin/" when my casperJs is installed on same path .If i am running /usr/bin/casperjs then its working fine. I will let you know in a code where the problem is occurring . I am wondering that why output is zero when it is creating file in /tmp folder but unable to load file . When i am directly running /usr/bin/casperjs /tmp/php-casperjs-SSGeG on terminal . It showing this error phantomjs://code/bootstrap.js:110 in __die phantomjs://code/bootstrap.js:110 in _die** I am working on UBUNTU.Do consider this request please. Thanks |
Hello @alwex It showing this error phantomjs://code/bootstrap.js:110 in __die** I think phantoms is not getting loaded on exec() function due to this its returning empty array. Thanks |
Hello @alwex public function start($url)
{
$this->_clear();
$step = <<<FRAGMENT
var casper = require('casper').create({
verbose: false,
logLevel: 'debug',
colorizerType: 'Dummy',
pageSettings: {
loadImages:false
}
});
//casper.userAgent('Mozilla/5.0 (Windows NT 6.0) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.41 Safari/535.1');
//phantom.setProxy('ltpc170d53a:c170d53a@ltp.viia.me','8945');
casper.start().then(function() {
this.open('$url', {
headers: {
'Accept': 'text/html'
}
});
});
casper.userAgent('Mozilla/5.0 (Windows NT 6.0) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.41 Safari/535.1');
FRAGMENT;
$this->addStep($step);
return $this;
} Please check whether i am setting userAgent on a correct position and is there anyway to check user-agent is setting fine or not. Thanks for awesomeness |
Hello there, I had this exact error and I was like running crazy to solve it because any solution found here or on stackoverflow didn't work for me. It happens that some frameworks for example cakephp, doesn't get correctly the vendors directory. I mean, you must have the autoload.php file to point at, and now the error won't happen. I didn't try casperjs but my web is running error clean now. |
was stuck on this error "Can not find CasperJS" then i changed setpath2casperjs to absolute path |
Ok, maybe it's not working for you, but for ubuntu distributions there is a problem with the phantomjs. @3zzy the steps I used are as follows: Does this help your case? |
@antoiba86 I attempted this as i'm using Ubuntu and unfortunately it didn't work either (although it may have contributed to me finding a successful workaround afterwards so i'd recommend trying this as well). My debug steps are below hopefully they might help someone else. I noticed that on my Laravel/Homestead box the path2casper was:
When running casperjs on terminal it was actually running in different directory:
Changing the path2casper to the above didn't work I echoed out exec() command and ran it in terminal and received an error telling me that casperjs was a directory, I navigated to the directory and found that my casperJS install was actually within the bin of that folder:
Changing the following lines in my Casper.php finally did the trick:
|
Hello everbody, I have a similar issue on my macOS Sierra system. I tried to install php-casperjs according to the Readme but did not succeed. You find my question on StackOverflow. Maybe one of you guys can help me there. |
@natterstefan Ok, you can do a few things to know what happen. You should go to your apache error.log or whatever systems use macOS. |
@antoiba86 Hello, thanks for your reply. Actually I was able to solve it. I do not what went wrong during the installation of |
Hi there @antoiba86 @alwex I hope any of you can help me. I have the same issue, I pasted the example to a PHP file and when I open it, I get this error: https://i.imgur.com/lrA8tin.png phantomjs and casperjs are completely installed on my computer because I can run casperjs files and they work perfectly on my end: https://i.imgur.com/awTgIYL.png For some reason, php-casperjs is not working for me and I already run Could any of you help me, please? ~ I have Windows 10 and I am using XAMPP v3.2.2. Thank you in advance! |
Your script is not taken correctly the path to casperjs-php. |
Thank you for responding @antoiba86, so I already have this included and it doesn't fix the issue, here's the screenshot of it: https://i.imgur.com/LgCxUQf.png maybe is there any mistake? |
The PHP script is in the same folder as the autoload file? |
Yes, because if not, there would be an error saying something like "autoload.php can't be found", but the error is: Class 'Browser\Casper' not found in C:\xampp\htdocs\web scraping\web scraping.php on line 4 |
Do you think I should try what natterstefan did? So maybe a clean installation of everything will fix it. |
Ok I think I fixed it by formatting my computer & installing windows again. But this is what I get now:
Any help? |
That is because, casperjs is not a environment variable and cannot use casperjs. |
Oh so is there a way to fix it? I just added |
Ok, I don't need more help... Due to these issues, I tried to find other ways to run CasperJS on PHP and I've just found this and it worked for me: https://stackoverflow.com/questions/25001258/cannot-pass-casperjs-result-back-to-php Anyways, the developer of php-casperjs, should fix all those bugs soon. Thank you for all your help @antoiba86 |
Hello, I'm having trouble running the example code.
I installed phantomjs and casperjs.
I installed php-casperjs
And when I run the example I get:
When I removed the:
namespace Browser;
from Casper.php and included Casper.php manually:
include 'vendor/phpcasperjs/phpcasperjs/src/Browser/Casper.php';
I get:
Finally I went through the Casper.php file and changed this:
private $path2casper = '/usr/local/bin/'; //path to CasperJS
for all paths I could think of without any success.
Could you please help me? thankyou
The text was updated successfully, but these errors were encountered: