Open algobasket opened 7 years ago
I have exactly the Same issue, still looking for a solution
@mohannadjaalouk its better to use python with selenium and phantom as browser
Please see PR #195
or use my fork repo, I've improved the path lookup here:
https://github.com/c9s/php-phantomjs/blob/master/src/JonnyW/PhantomJs/Engine.php#L68
I used this
$client->getEngine()->setPath('bin\\phantomjs.exe');
for the path double \ after bin
You are missing file name in your setPath()
function, it should be
setPath('bin' . D_S . 'phantomjs.exe') ;
@contacthe you way worked, but the problem is ... all error were gone but no response ... blank page.
{
"name": "qing/server",
"authors": [
{
"name": "Raymond",
"email": "773561801@qq.com"
}
],
"require": {
"php": ">=7.3",
"jonnyw/php-phantomjs": ">=4.1",
"jakoch/phantomjs-installer": "2.1.1-p08"
},
"scripts": {
"post-install-cmd": [
"PhantomInstaller\\Installer::installPhantomJS"
],
"post-update-cmd": [
"PhantomInstaller\\Installer::installPhantomJS"
]
},
"config": {
"bin-dir": "bin"
}
}
<?php
require 'vendor/autoload.php';
use JonnyW\PhantomJs\Client;
$client = Client::getInstance();
// https://phantomjs.org/download.html
// https://github.com/jonnnnyw/php-phantomjs/issues/142
$client->getEngine()->setPath(dirname(__FILE__).'/bin/phantomjs/bin/phantomjs.exe');
$width = 800;
$height = 600;
$top = 0;
$left = 0;
/**
* @see JonnyW\PhantomJs\Http\CaptureRequest
**/
$request = $client->getMessageFactory()->createCaptureRequest('https://www.runoob.com', 'GET');
$request->setOutputFile('./capture/file.jpg');
$request->setViewportSize($width, $height);
$request->setCaptureDimensions($width, $height, $top, $left);
/**
* @see JonnyW\PhantomJs\Http\Response
**/
$response = $client->getMessageFactory()->createResponse();
// Send the request
$client->send($request, $response);
PLEASE RESOLVE THIS ISSUE Fatal error: Uncaught exception 'JonnyW\PhantomJs\Exception\InvalidExecutableException' with message 'File does not exist or is not executable: E:\phantomjs\bin' in E:\XAMPP\htdocs\freelancing-work\scrapping\www.referenceusa.com\vendor\jonnyw\php-phantomjs\src\JonnyW\PhantomJs\Engine.php:245 Stack trace: #0 E:\XAMPP\htdocs\freelancing-work\scrapping\www.referenceusa.com\vendor\jonnyw\php-phantomjs\src\JonnyW\PhantomJs\Engine.php(109): JonnyW\PhantomJs\Engine->validateExecutable('E:\phantomjs\bi...') #1 E:\XAMPP\htdocs\freelancing-work\scrapping\www.referenceusa.com\scrap.php(11): JonnyW\PhantomJs\Engine->setPath('E:\phantomjs\bi...') #2 {main} thrown in E:\XAMPP\htdocs\freelancing-work\scrapping\www.referenceusa.com\vendor\jonnyw\php-phantomjs\src\JonnyW\PhantomJs\Engine.php on line 245