Delay function?
metallurgical opened this issue · comments
Norlihazmey Ghazali commented
May i know, is there a delay function which the same to this Delay Page Render?
MrJosh commented
Hey, I hope you doing well.
Yeah, The \PhantomJs::request
method is actually a shortcut for $client->getMessageFactory()->createRequest('http://jonnyw.me')
It returns JonnyW\PhantomJs\Http\Request
object.
You can do something like this
$request = \PhantomJs::get('https://www.google.com/').setDelay(1000);
$response = \PhantomJs::send($request);
if($response->getStatus() === 200) {
// Dump the requested page content
var_dump($response->getContent());
}
If you want to access to methods like createRequest
or createCaptureRequest
you can have them with getClient
method.
you can get client like:
$client = \PhantomJs::getClient();
$request = $client->getMessageFactory()->createCaptureRequest('http://jonnyw.me');
$request->setDelay($delay);
or maybe if you had custom client instance you can set it like:
\PhantomJs::setClient($client);
I hope this will help you. Good luck. 👍
Norlihazmey Ghazali commented
Thanks for pointing it out man. Thanks again