This is a very simple program that uses PHP's file_get_contents function to collect Baidu data, and then parses the data through simplexml_load_String, so that the data is saved in an array, which we can use conveniently.
The code is as follows
代码如下 |
复制代码 |
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;
}
|
|
Copy code |
|
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;
}
http://www.bkjia.com/PHPjc/631639.htmlwww.bkjia.comtrue
http: //www.bkjia.com/PHPjc/631639.htmlThis is a very simple program that uses PHP's file_get_contents function to collect Baidu data, and then loads it through simplexml_load_String The data is parsed, so the data is saved to a...
Statement: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