php 获取百度的暖词数据

WBOY
Release: 2016-06-13 13:16:02
Original
913 people have browsed it

php 获取百度的热词数据
/**
* 获取百度的热词
* @user   小杰
* @from   http://www.isharey.com/?p=354
* @return array  返回百度的热词数据(数组返回)
*/

/**
 * 获取百度的热词
 * @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;
}
Copy after login

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!