简体   繁体   中英

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.

Example:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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