一段简单的php代码抓取百度热词
/**
* 获取百度热词
* @author tarylei
* @ encoding GBK
* @link weibo.com/4699640
* @ from http://top.baidu.com/rss_xml.php?p=top10
* @ return array 返回百度24小时内热词
*/
function get_baidu_hotkeyword(){
$baidu_data = file_get_contents('http://top.baidu.com/rss_xml.php?p=top10');
$reg = <<<ABC
|<th>\d{1,2}</th>\s*<td><a\s*href="\S+"\s*target="_blank"\s*>(.*?)</a></td>|ims
ABC;
preg_match_arr($reg, $baidu_data, $result);
return $result[1];
}
