sjtprruy 2008-4-7 14:30
最简单的PHP读取RSS内容
我们可以读取csdn的PHP的发布最新信息..................
=============begin php code===================
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>CSDN RSS-PHP信息</title>
<meta name="generator" content="editplus" />
<meta name="author" content="sjtprruy" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>CSDN-rss最新消息</title>
</head>
<body>
<?php
$xmlfile = @fopen("http://forum.csdn.net/Rss/PHP/UnClosedList", "r");//参考http://forum.csdn.net/Rss/PHP/UnClosedList
if(!$xmlfile)
die("不能打开RSS文件,请稍候再刷新!");
$readfile = fread($xmlfile ,40000);
$searchfile = eregi("<item>(.*)</item>", $readfile ,$arrayreg);
$filechunks = explode("<item>", $arrayreg[0]);
$count = count($filechunks);
echo "<table bgcolor=\"#ffffff\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\" bordercolordark=\"#ffffff\"
bordercolorlight=\"#000000\">";
echo "<th colspan='3'>最新新闻</th>";
echo "<tr><td>标题</td><td>发布者</td><td>发布时间</td></tr>";
for($i=1 ; $i<=$count-1 ;$i++)
{
ereg("<title>(.*)</title>",$filechunks[$i], $title);//标题
ereg("<link>(.*)</link>",$filechunks[$i], $links);//链接网址
ereg("<author>(.*)</author>",$filechunks[$i],$author);//发布者
ereg("<pubDate>(.*)</pubDate>",$filechunks[$i],$pubDate);//发布时间
ereg("<description>(.*)</description",$filechunks[$i],$desc);//取内容部分
echo "<tr><td>";
echo "<a href =".$links[1]." title=".$desc[1].">".$title[1]."</a>";
echo "</td><td>";
echo $author[1];
echo "</td><td>";
echo $pubDate[1];
echo "</td></tr>";
}
echo "</table>";
?>
</body>
</html>
=============end php code===================
抓到rss内容基本完成。。。
opqr175 2008-9-22 14:35
丽江:迷离销魂吻醒我的天堂梦
听着脚下潺潺流动的小溪,清脆的缓流让我加倍感觉到房间的阴冷,梦中的丽江不应是如此的令人迫不及待的想关上窗户,[url=http://www.shengbaoluojipiao.cn]北京到圣保罗机票[/url],也许适应了北方的暖气,一时之间只想把自己蜷进有电热毯的被窝,打开电脑渴望告诉朋友我已经到达了丽江—-一个令我神往的城市。无奈电脑不知是不是水土不服还是被我一路上折磨的,开机就死,试了n遍依旧无法将它征服!我的情绪有点低落,一向心直口快的人在此刻,在一个我盼望已久的城市被压抑了。今夜无眠,也许是情急的兴奋,但是更严重的是我的水土不服,[url=http://www.weiyenajipiao.cn/]北京到维也纳机票[/url]空气中微薄的氧含量打乱了我平稳的呼吸,我开始喘不上气,不知这个[url=http://www.dongjingjipiao.cn]北京到东京机票[/url]……