百度热词 一段简单的php代码抓取百度热词
一段简单的php代码抓取百度热词 [代码片段(16行)]
/** * 获取百度热词 * @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]; }
- 上一篇:正则匹配 php取得网页上的所有链接
- 下一篇:当前url php获取当前url
精彩图集
精彩文章