php 取得百度的熱詞數據

巴扎黑
發布: 2016-11-24 10:03:42
原創
1299 人瀏覽過

/** 
* 取得百度的熱詞 
* @user   小傑 
* @from   http://www.isharey.com/?p=354 
* @return array  回傳百度的熱詞資料(數組返回)*/ 

Java代碼  

/**

 * 取得百度的熱詞 

 * @user   小傑 

 * @from   http://www.isharey.com/?pp=3554177572L57LL5LLL5L5LL地區:L59詞的來回複位回傳*:585722572297(IL)):

 */  

function getBaiduHotKeyWord()  
{  
    $templateRss = file_get_contents('http://top.baidu.com/rss_xml.php?p=top10');  
    If (preg_match(&#39;/<table>(.*)<\/table>/is&#39;, $templateRss, $_description)) {  
        $templateRss = $_description [0];  
        $templateRss = str_replace("&", "&amp;", $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;  
}
登入後複製

相關標籤:
php
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!