jeudi 1 septembre 2016

PHANTOMJS PHP : Empty response object

When I try to save the file locally, the response object is returned null .The page I'm trying to capture takes a lot of loading time for which I need a callback to notify me when all page resources are completely loaded. Is my approach correct ?

When not trying to save the file locally the response object returned is not null.

Here's my code:

$client = Client::getInstance();
$client->getEngine()->setPath('path/to/phantomjs');
    $client->isLazy();

    $request  = $client->getMessageFactory()->createPdfRequest('http://google.com');
    $response = $client->getMessageFactory()->createResponse();

    $file = 'path/binfile.pdf';

    $request->setOutputFile($file);

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

How do I achieve and know when all the page resources are completely loaded ?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire