如http://top.baidu.com/buzz?b=26&c=1&fr=topcategory_c1
------解决思路----------------------
帶輸出的完整例子,你好好學習下。

中間你想改什麼,直接改就可以了。
function getContent($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_TIMEOUT, 300);
$response = curl_exec($ch);
if($error=curl_error($ch)){
die($error);
}
curl_close($ch);
$content = iconv('GBK','UTF-8//IGNORE',$response);
return $content;
}
function getKeywords($content){
// keywords
preg_match_all('/(.*?)<\/td>/is', $content, $keywords);
$data = $keywords[1];
$result = array();
foreach($data as $val){
preg_match_all('/(.*?)<\/a>/is', $val, $tmp);
array_push($result, array('name'=>$tmp[2][0],'url'=>'http://top.baidu.com'.substr($tmp[1][0],1)));
}
return $result;
}
function getTc($content){
// tc
preg_match_all('/(.*?)<\/td>/is', $content, $tc);
$data = $tc[1];
$result = array();
foreach($data as $val){
preg_match_all('/(.*?)<\/a>/is', $val, $tmp);
array_push($result, array('brief'=>$tmp[1][0], 'news'=>$tmp[1][1], 'tieba'=>$tmp[1][2]));
}
return $result;
}
function getNum($content){
// last
preg_match_all('/(.*?)<\/td>/is', $content, $last); //icon-rise up icon-fall down
$data = $last[1];
$result = array();
foreach($data as $val){
preg_match_all('/(.*?)<\/span>/is', $val, $tmp);
array_push($result, array('flag'=>str_replace('icon-','',$tmp[1][0]), 'num'=>$tmp[2][0]));
}
return $result;
}
$url = 'http://top.baidu.com/buzz?b=340&c=1&fr=topbuzz_b339_c1';
$content = getContent($url);
$result = array();
$keywords = getKeywords($content);
$tc = getTc($content);
$num = getNum($content);
for($i=0,$len=count($keywords); $i<$len; $i++){
$tmp = array(
'name' => $keywords[$i]['name'],
'url' => $keywords[$i]['url'],
'brief' => $tc[$i]['brief'],
'news' => $tc[$i]['news'],
'tieba' => $tc[$i]['tieba'],
'flag' => $num[$i]['flag'],
'num' => $num[$i]['num']
);
array_push($result, $tmp);
}
?>
baidu
$i = 1;
foreach($result as $val){
?>
=$i ?>
">=$val['name'] ?>
">簡介
">新聞
">貼吧
=$val['num'] ?>
$i++;
}
?>