<?php

echo "OK";

// phpinfo();
//取得指定位址的內容,並儲存至text  
$text=file_get_contents('https://www.yidaiyilu.gov.cn/info/iList.jsp?cat_id=10360');  

$text=str_replace(array("\r","\n","\t","\s"), '', $text); 
// var_dump($text);
//取出div標籤且id為PostContent的內容,並儲存至陣列match  


preg_match('/<div[^>]*class="list_right left"[^>]*>(.*?) <\/div>/si',$text,$match);

preg_match('/<ul[^>]*class="commonList_dot"[^>]<li[^>]*>(.*?) <\/div>/si',$text,$match);

<ul class="commonList_dot"><li>
                                                   

preg_match('/<li[^>]*>/Ui', $match[0], $m);


  
//印出match  
//print_r($match);
/*
$length = count($match);
while ($i <= $length) {
 echo($match[$i]);
 $i++;
}

*/
?>

标签: 抓取

分享到: