这篇文章主要为大家详细介绍了php 抓取百度热词的简单示例,具有一定的参考价值,可以用来参考一下。
对一段简单的php代码抓取百度热词感兴趣的小伙伴,下面一起跟随四海网的小编两巴掌来看看吧!
/**
* 一段简单的php代码抓取百度热词
*
* @param
* @author 五一二笔记网: www.q1010.com
* 获取百度热词
* @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];
}
/*** 来自四海网(www.q1010.com) ***/
本文来自:http://www.q1010.com/173/715-0.html
注:关于php 抓取百度热词的简单示例的内容就先介绍到这里,更多相关文章的可以留意四海网的其他信息。
关键词:百度
四海网收集整理一些常用的php代码,JS代码,数据库mysql等技术文章。