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

<div class="codetitle"><a style="CURSOR: pointer" data="94921" class="copybut" id="copybut94921" onclick="doCopy('code94921')"> 代码如下:

<div class="codebody" id="code94921">
<?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());

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...