Php code for retrieving Baidu's popular word data and returns an array
Php code for retrieving Baidu's popular word data and returns an array
The Code is as follows:
/**
* Get Baidu's buzzwords
* @ User Xiaojie
* @ From http://www.isharey.com /? P = 354
* @ Return array returns Baidu's buzzword data (array return)
*/
Function getBaiduHotKeyWord ()
{
$ TemplateRss = file_get_contents ('HTTP: // top.baidu.com/rss_xml.php? P = top10 ');
If (preg_match ('/
(. *) <\/Table>/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 ;} print_r (getBaiduHotKeyWord ());