Home > Backend Development > PHP Tutorial > PHP code to obtain Baidu's hot word data_PHP tutorial

PHP code to obtain Baidu's hot word data_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-21 15:21:11
Original
1032 people have browsed it

复制代码 代码如下:

/**
* Get Baidu’s hot words
* @user 小杰
* @from http://www.isharey.com/?p=354
* @return array Return Baidu’s hot word data (Array return)
*/
function getBaiduHotKeyWord()
{
$templateRss = file_get_contents('http://top.baidu.com/rss_xml.php?p=top10');
If (preg_match('/(.*)
/is', $templateRss, $_description)) {
$templateRss = $_description [0];
$templateRss = str_replace("&", "&", $templateRss);
}
$templateRss = "" . $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());

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/324960.htmlTechArticle复制代码 代码如下: ?php /*** Get Baidu's hot words * @user Xiaojie * @from http://www.isharey.com/?p=354 * @return array Return Baidu's hot word data (array return)*/ functi...
Related labels:
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template