我使用簡單的HTML DOM解析器刮產品從一個網站,我寫了下面的代碼爲這個PHP:網頁加載無限的時間
<?php
error_reporting(E_ALL);
require_once('lib/simple_html_dom.php');
set_time_limit(0);
ini_set('memory_limit', '1024M');
ini_set('max_input_time ', '99999');
$url='http://www.yourpoolhq.com/pool-supplies/aboveground/pool-liners/round/unibead.html';
$html = file_get_html($url);
if(is_object($html)){
foreach ($html->find('div.category-products') as $elem){
$data = $elem->innertext;
$strdata = str_get_html($data);
foreach ($strdata->find('a') as $a) {
if($a->plaintext!=''){
get_detail_page($a->href);
flush();
}
flush();
}
unset($data);
unset($strdata);
}
$html->clear();
unset($html);
}
function get_detail_page($href){
$details = file_get_html($href);
if(is_object($details)){
foreach ($details->find('h1') as $ess) {
//print_r($ess); this has data
echo $ess->plaintext; // not getting this, Why this is not printing. x-(
flush();
}
$details->clear();
unset($details);
}
flush();
}
?>
沒有得到什麼錯誤我在做什麼在這裏。任何想法的傢伙。
編輯:我已經更新了代碼在某些地方添加刷新並評論錯誤部分。
向我們展示您的file_get_html()? – bwoebi 2013-04-23 17:43:16
它的功能simple_html_dom.php http://simplehtmldom.sourceforge.net – ravisoni 2013-04-23 17:50:32
清除一個垃圾代碼,看看是否有效。並添加每一塊代碼,看看是什麼導致問題 – Reshad 2013-04-23 17:42:36