您好,欢迎访问一九零五行业门户网

php file_get_contents获取百度热词代码_PHP教程

这是一段很简单的程序利用了php的file_get_contents函数来采集百度的数据,然后通过simplexml_load_string把它数据解析出来,这样数据就保存到了一个数组,我们就可以方便的利用了。
 代码如下 复制代码
function getbaiduhotkeyword()
{
    $templaterss = file_get_contents('http://top.baidu.com/rss_xml.php?p=top10');
    if (preg_match('/
(.*)
/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;
}
http://www.bkjia.com/phpjc/631639.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/631639.htmltecharticle这是一段很简单的程序利用了php的file_get_contents函数来采集百度的数据,然后通过simplexml_load_string把它数据解析出来,这样数据就保存到了一...
其它类似信息

推荐信息