php Webページ情報のキャプチャ

3237 ワード

index.php



<?php
include_once 'simple_html_dom.php';
//  html       
$html = file_get_html('http://paopaotv.com/tv-type-id-5-pg-1.html');
//A-Z           id=letter-focus  div class= letter-focus-item dl   , find       
$listData=$html->find("#letter-focus .letter-focus-item");//$listData     

foreach($listData as$key=>$eachRowData){
  $filmName=$eachRowData->find("dd span",0)->plaintext;//      

  $filmUrl=$eachRowData->find("dd a",0)->href;//  dd          

  //         
  $filmInfo=file_get_html("http://paopaotv.com".$filmUrl);
  $filmDetail=$filmInfo->find(".info dl");
  foreach($filmDetail as $film){
    $info=$film->find("dd");
    $row=null;
    foreach($info as $childInfo){
      $row[]=$childInfo->plaintext;
    }
    $cate[$key][]=join(",",$row);//            
  }
}
?>

<table border="1px solid red" width="100%">
  <tr>
    <th>  </th>
    <th>  </th>
    <th>  </th>
    <th>  </th>
    <th>  </th>
    <th>  </th>
    <th>  </th>
    <th>  </th>
  </tr>


<?php foreach ($cate as $val){
echo "<tr>";
  for ($i=0; $i < count($val)-1; $i++) { 

    echo "<td>".$val[$i]."</td>";
  }    
echo "</tr>";
} ?>

</table>

<?php 
echo "<pre>";
print_r($cate);
echo "</pre>";

?>

:files.cnblogs.com/files/qhorse/getspider.rar