+ -
当前位置:首页 → 问答吧 → Qzone rss的利用

Qzone rss的利用

时间:2007-10-11

来源:互联网

复制PHP内容到剪贴板
PHP代码:

<?php
$doc = new DOMDocument();
$doc->load("[url=http://feeds.qzone.qq.com/cgi-bin/cgi_rss_out?uin=153080931]http://feeds.qzone.qq.com/cgi-bin/cgi_rss_out?uin=153080931[/url]");   //这个是qzone feeds的地址只要修改后面uin=
$items = $doc->getElementsByTagName("item");     // 一个item 是一个内容页
$i=0;
foreach ($items as $item){
//
$title = $item->getElementsByTagName("title");                           //获取title节点
$titles = $title->item(0)->nodeValue;                                          //获取title得内容
$arr[$i]['title']= mb_convert_encoding($titles,"gb2312","utf-8");     //由于是utf-8 转换为中文 gb2312 ,需要mbstring的支持

//
$pubdates= $item->getElementsByTagName("pubDate");
$pubdate =$pubdates->item(0)->nodeValue;
$arr[$i]['pubdate']=mb_convert_encoding($pubdate,"gb2312","utf-8");
$descriptions= $item->getElementsByTagName("description");
$description =$descriptions->item(0)->nodeValue;
$arr[$i]['description']=mb_convert_encoding($description,"gb2312","utf-8");
$i++;
}
print_r($arr);
?>

代码很简单可以查找一下domdocument得一些相关只是就可以了。

[ 本帖最后由 morsth 于 2007-10-11 14:41 编辑 ]

作者: morsth   发布时间: 2007-10-11

dom是个好人

作者: gently   发布时间: 2007-10-11