file_get_html在同一个脚本中多次

时间:2012-02-11 21:49:52

标签: php

我正在使用简单的html dom解析器。当我请求像file_get_html()这样的页面时,我得到了2个值。一个是标题,另一个是网址。在此我想再次file_get_html()

但是我得到第二次遍历的类似数据。

喜欢这个脚本:

foreach($urls as $value) {
  $html=file_get_html($value);

  foreach($html->find('div[class=data] a') as $content) {
       $url2='http://abc.com/'.$content->href;
       $childHtml=file_get_html($url2);

       echo $childHtml; //Proble is here i am getting the previous data-->html
  }
}

我在这里做错了什么?

这是主要的抓取代码

$urls=GenerateURLS($currentmonth);     
$tracker=0;
$urlHolderArray=array();

foreach ($urls as $value) {
  $html=file_get_html($value);  //Here I am requesting the html dom

  foreach ($html->find('div[id=centrepanel] div[class=events_listing_container]  div[class=events_info_container] div[class=events_image] a') as $content) {
    $proxyURL="http://www.junkclub.com/".$content->href;
    array_push($urlHolderArray,$proxyURL);          
  }
}

echo '<pre/>';
print_r($urlHolderArray);
echo '<pre/>';

foreach ($urlHolderArray as $link) {
  $htmlCon=file_get_html($link);
}

echo $htmlCon;

0 个答案:

没有答案
相关问题