Skip to content
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

Internal error 500 with lazy load #107

Closed
DarthMoleman opened this issue Jun 26, 2016 · 3 comments
Closed

Internal error 500 with lazy load #107

DarthMoleman opened this issue Jun 26, 2016 · 3 comments

Comments

@DarthMoleman
Copy link

Hi,

when I test with http://jonnyw.kiwi/tests/test-lazy.php, everything is ok (got the page and the 'loaded' content). I have an internal error after several minutes with a website I'm scrapping (but no error on 'basic usage script' with delay).

Here is my code:

`
require 'vendor/autoload.php';
use JonnyW\PhantomJs\Client;

$url = "http://jonnyw.kiwi/tests/test-lazy.php";

   $client = Client::getInstance();
   $client->isLazy();

    $request  = $client->getMessageFactory()->createRequest();
    $request->setMethod('GET');
    $request->setUrl($url);
    //$request->setTimeout(5000);

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

    echo $response->getContent();`

Thanks for your help.

ps: sorry for my english, it's not my primary language.

@jonnnnyw
Copy link
Owner

Would you be able to provide me with the URL of the website you are scraping so I can test it myself?

@DarthMoleman
Copy link
Author

Sorry, I forgot the link.

Url = http://www.canadiantire.ca/fr/pdp/dewalt-20v-max-li-ion-drill-impact-driver-kit-0543177p.html

Best regards.

jonnnnyw added a commit that referenced this issue Jun 28, 2016
@jonnnnyw
Copy link
Owner

I managed to find out what the issue was. The lazy script was logging loaded resources to the debug output but this was causing the script to hang when their were are large number of resources. I have removed resource logging and it successfully loads the URL you provided.

I have released v4.5.1 with the fix.

You will want to clear the compiler cache before trying again:

$client = Client::getInstance();
$client->getProcedureCompiler()->clearCache();

Remember to remove the $client->getProcedureCompiler()->clearCache() from your script after you've cleared the cache as this will slow down execution massively.

Let me know how you get on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants