热词 php 获取百度的热词数据的代码

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

热词 php 获取百度的热词数据的代码

  2021-03-18 我要评论
想了解php 获取百度的热词数据的代码的相关内容吗,在本文为您仔细讲解热词的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:热词,下面大家一起来学习吧。
复制代码 代码如下:

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

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们