php 獲取百度的熱詞數(shù)據(jù)的代碼
更新時間:2012年02月18日 12:56:05 作者:
php 獲取百度的熱詞數(shù)據(jù)的代碼,返回數(shù)組
復制代碼 代碼如下:
<?php
/**
* 獲取百度的熱詞
* @user 小杰
* @from http://www.isharey.com/?p=354
* @return array 返回百度的熱詞數(shù)據(jù)(數(shù)組返回)
*/
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實現(xiàn)統(tǒng)計二進制中1的個數(shù)算法示例
這篇文章主要介紹了php實現(xiàn)統(tǒng)計二進制中1的個數(shù)算法,結合實例形式分析了php字符串遍歷、判斷、統(tǒng)計等相關操作技巧,需要的朋友可以參考下2018-01-01

