php 获取百度的热词数据的代码
2018-10-12 14:08
417 查看
<?php
/**
* 获取百度的热词
* @user 小杰
* @from http://www.isharey.com/?p=354
* @return array 返回百度的热词数据(数组返回)
*/
function getBaiduHotKeyWord()
{
$templateRss = file_get_contents('http://top.baidu.com/rss_xml.php?p=top10');
If (preg_match('/<table>(.*)<\/table>/is', $templateRss, $_description)) {
$templateRss = $_description [0];
$templateRss = str_replace("&", "&", $templateRss);
}
$templateRss = "<?xml version=\"1.0\" encoding=\"GBK\"?>" . $templateRss;
$xml = simplexml_load_String($templateRss);
foreach ($xml->tbody->tr as $temp) {
if (!empty ($temp->td->a)) {
$keyArray [] = trim(($temp->td->a));
}
}
return $keyArray;
}
print_r(getBaiduHotKeyWord());
您可能感兴趣的文章:
相关文章推荐
- 获取本批数据备份文件名 Monxin专用(PHP代码函数)
- PHPExcel下载(从数据库获取数据)示例代码
- 跟着百度学PHP[17]-PHP扩展CURL的模拟登陆并获取数据
- 用PHP获取Google AJAX Search API 数据的代码
- php 获取各种日期周月年季度的数据 代码
- php 表单数据的获取代码
- php获取从百度搜索进入网站的关键词的详细代码
- PHP无限循环获取MySQL中的数据实例代码
- php 获取各种日期周月年季度的数据 代码
- php 表单数据的获取代码
- PHP获取POST数据的几种方法汇总
- 用php实现的获取网页中的图片并保存到本地的代码
- K2与OData和Swagger集成,从任何设备无需代码获取数据
- 练习 2017-08-13 获取进程数据-编译和运行Java代码 问题在截图上 留待解决。
- vue.js获取数据库数据实例代码
- PHP获取地址栏信息的代码