PhantomJS PHP无法完全加载页面

时间:2018-10-19 17:29:39

标签: php phantomjs

我正在通过以下方式通过PhantomJS PHP库在PHP中使用PhantomJS: https://github.com/jonnnnyw/php-phantomjs

这是我的PHP代码:

<?php

require_once('vendor/autoload.php');

use JonnyW\PhantomJs\Client;

$client = Client::getInstance();

$client->isLazy();

$request  = $client->getMessageFactory()->createRequest();
$response = $client->getMessageFactory()->createResponse();

$request->setMethod('GET');
$request->setUrl('https://www.minds.com/JordonDejesus/blog/this-vs-that-provides-trustworthy-phone-comparisons-889137222911426560');

$client->send($request, $response);

if($response->getStatus() === 200) {
   echo $response->getContent();
}

?>

此URL似乎使用某些Javascript API加载了内容。当我使用幻像运行它时,在浏览器中运行时会出现“未找到”错误。

我使用cURLfile_get_contents得到了相同的响应,因此phantomJS由于某种原因没有采取任何措施。我的代码中有$client->isLazy(),应该等待所有资源加载完毕然后呈现页面。

0 个答案:

没有答案
相关问题