手机
当前位置:查字典教程网 >编程开发 >php教程 >php 获取百度的热词数据的代码
php 获取百度的热词数据的代码
摘要:复制代码代码如下:tbody->tras$temp){if(!empty($temp->td->a)){$keyArray[]=trim((...

复制代码 代码如下:

<?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());

【php 获取百度的热词数据的代码】相关文章:

php 批量查询搜狗sogou代码分享

php动态绑定变量的用法

php curl 获取https请求的2种方法

类的另类用法--数据的封装

PHP滚动日志的代码实现

php获取json数据所有的节点路径

php eval函数一句话木马代码

分页显示Oracle数据库记录的类之二

php数据库备份脚本

php截取指定2个字符之间字符串的方法

精品推荐
分类导航