Heim >Backend-Entwicklung >PHP-Tutorial >PHP ruft Baidus Hot-Word-Daten ab
/**
* Baidus heiße Wörter abrufen
* @Benutzer Xiaojie
* @von http://www.isharey.com/?p=354
* @return array Baidus heiße Wortdaten zurückgeben (Array return )
*/
Java-Code
/**
* Holen Sie sich Baidus heiße Worte
* @user Xiaojie
* @from http://www.isharey.com/?p=354
* @return array Gibt Baidus Hot-Word-Daten zurück (Array-Return)
*/
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; }