php 获取百度的热词数据的代码

前端之家收集整理的这篇文章主要介绍了php 获取百度的热词数据的代码前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

<div class="codetitle"><a style="CURSOR: pointer" data="94921" class="copybut" id="copybut94921" onclick="doCopy('code94921')"> 代码如下:

<div class="codebody" id="code94921"> @H_403_2@<?PHP @H_4032@/** @H403_2@ 获取百度的热词 @H_403_2@ @user 小杰 @H_4032@* @from http://www.isharey.com/?p=354 @H403_2@ @return array 返回百度的热词数据(数组返回) @H_403_2@/ @H_4032@function getBaiduHotKeyWord() @H4032@{ @H403_2@$templateRSS = file_get_contents('http://top.baidu.com/RSS_xml.PHP?p=top10'); @H_403_2@If (preg_match('/<table>(.*)<\/table>/is',$templateRSS,$description)) { @H403_2@$templateRSS = $description [0]; @H403_2@$templateRSS = str_replace("&","&",$templateRSS); @H_4032@} @H403_2@$templateRSS = "<?xml version=\"1.0\" encoding=\"GBK\"?>" . $templateRSS; @H_403_2@$xml = simplexml_load_String($templateRSS); @H_4032@foreach ($xml->tbody->tr as $temp) { @H4032@if (!empty ($temp->td->a)) { @H4032@$keyArray [] = trim(($temp->td->a)); @H4032@} @H4032@} @H4032@return $keyArray; @H4032@} @H403_2@printr(getBaiduHotKeyWord()); @H403_2@

猜你在找的PHP相关文章