简体   繁体   English

简单的HTML Dom PHP

[英]Simple HTML Dom PHP

help me please... 请帮帮我...

image -> my result 图片-> 我的结果

my testing result, i don't know why? 我的测试结果,我不知道为什么?

price("http://www.example.com/"); -> work
price("http://www.example2.com/"); -> not work

try switch line. 尝试切换线路。

price("http://www.example2.com/"); -> work
price("http://www.example.com/"); -> not work

Here's my script... 这是我的剧本...

<?php
include_once('simple_html_dom.php');

function price($url){
  $html = file_get_html($url);

  foreach($html->find('span[class=col-right]') as $li){
       echo $li->innertext;
  }
}

price("http://www.example.com/");
price("http://www.example2.com/");
?>

Due to php5 circular references memory leak, after creating DOM object, you must call $dom->clear() to free memory if call file_get_dom() more then once. 由于php5循环引用内存泄漏,因此在创建DOM对象后,如果再调用一次file_get_dom(),则必须调用$ dom-> clear()释放内存。

Example: 例:

$html = file_get_html(...); 
// do something... 
$html->clear(); 
unset($html);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM