ホームページ  >  記事  >  バックエンド開発  >  php は Baidu の最新イベントを取得します

php は Baidu の最新イベントを取得します

WBOY
WBOYオリジナル
2016-06-13 13:18:09855ブラウズ

php Baidu から最新のイベントを取得します

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("&", "&amp;", $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 までご連絡ください。