最新消息: 新版网站上线了!!!

php读取rss xml 百度新闻的源码下载

header( 'Content-Type: text/html; charset=utf-8' );

error_reporting(E_ALL);
ini_set('display_errors', true);

include './Rss.php'; // include library

$Rss = new Rss; // create object

/*
	XML way
*/
try {
    $feed = $Rss->getFeed('http://news.baidu.com/n?cmd=1&class;=internet&tn;=rss', Rss::XML);
        foreach($feed as $item)	{
        echo "$item[title]\n";
        //echo "".date('Y-m-d', strtotime($item['date']))."\n";
        //	echo "Category: $item[category]\n";
        //	echo "\n$item[description]\n";

    }

}
catch (Exception $e) {
    echo $e->getMessage();
}

转载请注明:谷谷点程序 » php读取rss xml 百度新闻的源码下载