首頁  >  文章  >  後端開發  >  php 取得百度最新事件

php 取得百度最新事件

WBOY
WBOY原創
2016-06-13 13:18:09855瀏覽

php 获得百度最新事件

function getBaiduHotKeyWord() 
   { 
    $templateRss = file_get_contents('http://top.baidu.com/rss_xml.php?p=shijian'); 
    If (preg_match('/<table>(.*)<\/table>/is', $templateRss, $_description)) { 
    $templateRss = $_description[0]; 
    $templateRss = str_replace("&", "&", $templateRss); 
    } 
   $templateRss = "<?xml version=\"1.0\" encoding=\"GBK\"?>".trim($templateRss); 
   $xml = simplexml_load_String($templateRss); 
   foreach ($xml->tbody->tr as $temp) { 
    if (!empty ($temp->td->a)) { 
      $keyArray [] = trim(($temp->td->a)); 
    } 
   } 
   return $keyArray; 
   } 

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn