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

Script dying in parseStr #10

Open
quinxy opened this issue Feb 9, 2016 · 1 comment
Open

Script dying in parseStr #10

quinxy opened this issue Feb 9, 2016 · 1 comment

Comments

@quinxy
Copy link

quinxy commented Feb 9, 2016

For several hours I thought I might be going crazy, and then I realized pQuery is die-ing/exit-ing under some unknown conditions while executing parseStr(). About 1 in 5 times (a guess) I call it on a web page (fetched via file_get_contents()) it will kill my script.

The entirety of the pQuery-related code I'm calling is:

$html = file_get_contents($url);
// It always reaches here
$dom = pQuery::parseStr($html);
// It sometimes does NOT reach here
$html2 = $dom->query('div[class="col-xs-12 col-sm-6 col-md-5 col-lg-4"]')->html();
$dom2 = pQuery::parseStr($html2); // I'm doing this second parseStr because I can't find an equivalence to jquery $('#foo').find('#bar')
$imageUrl = $dom2->query('img')->attr('src');

I do not have a sample of the HTML which causes the dying... I'll try to collect that later and add it. The actual contents seem like they might not prove all that relevant because I'm basically working through a list of URLs and when I retry (after the script death) it works fine with the same URL (it isn't stuck on that URL) and with the pQuery code disabled the script works fine, so it's not a case where the $html it is given is ever "" or null.

@tburry
Copy link
Owner

tburry commented Mar 23, 2016

Do you have any other information about this? When things randomly die like this my guess would be memory limit. You are looping through a list and eventually the memory goes too high. Running with error reporting and/or an xdebug enabled version of PHP might shed more light.

If you can get me any more information I'll do my best to hunt this down.

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