简单的HTML DOM Parser崩溃

时间:2016-06-22 19:18:59

标签: php memory-leaks simple-html-dom

当您将大型HTML页面加载到simple_html_dom时,它会崩溃。当我解析Washington时,它会有效,但是当我解析las vegas时,它无法正常工作并显示此错误。

PHP Fatal error: Call to a member function find() on a non-object in /var/www/html/city2.php on line 20

这是代码

<?php

function httpGet($url)
{
    $ch = curl_init();  

    curl_setopt($ch,CURLOPT_URL,$url);
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
//  curl_setopt($ch,CURLOPT_HEADER, false); 

    $output=curl_exec($ch);

    curl_close($ch);
    return $output;
}
include_once('simple_html_dom.php');
$url="http://www.cityvibe.com/lasvegas/Escorts/";
$parse=httpGet($url);
$html = str_get_html($parse);
for ($y = 0; $y <= 10; $y++) {
$ret = $html->find('.image-link',$y)->href;
$rep=str_replace("//","http://",$ret);
$esc=httpGet($rep);
$grep=str_get_html($esc);
$ret2 = $grep->find('.post-name',0)->innertext;
echo $ret2;
?>

我试图修复内存泄漏,但它仍无法正常工作

PHP Simple HTML Dom Parser Memory Leak / Usage

任何解决此问题的方法?

0 个答案:

没有答案