2006-08-16
RSS Feed autodiscovery.
使用一些浏览器的浏览某个页面时会提示你这个页面有那些Rss源。她时怎样做的呢??
不过是在HTML里的部分里加一行代码,类似:
href="http://www.zhangyining.net/weblog/rss/rss.pl"/>
这行代码的作用就是告诉访问该页面的客户端程序(浏览器,RSS Reader,或者是RSS聚合
器)该页面提供RSS Feed以及该Feed的地址,这样,客户端程序可以直接反馈给用户提示用
户可以订阅的内容(例子:桌面或者基于浏览器的RSS Reader),或者自动聚合内容(例子
:RSS搜索引擎)。
Ok。 我用java实现这一功能。代码如下。。需要nekohtml-0.9.5.jar 和 xercesImple-2.6.2.jar
/**
* This function is Feed Autodiscovery, You just need passing the url, It would
* return the feeds.
*
* Rule, gets the elements "", check the type attribute whether is rss-xml type,
* if true, get the href attribute.
*
* @param url the page url that need to discovery
* @return Feed list
*/
public static List discoveryFeedList(String url){
List rt = new ArrayList();
if (StringUtils.isBlank(url)){
return rt;
}
DOMParser parser = new DOMParser();
try {
parser.parse(url);
}catch(Exception e){
// ignore the exception; just return empty value;
return rt;
}
NodeList list = parser.getDocument().getElementsByTagName("link");
for(int i=0; i
不过是在HTML里的部分里加一行代码,类似:
href="http://www.zhangyining.net/weblog/rss/rss.pl"/>
这行代码的作用就是告诉访问该页面的客户端程序(浏览器,RSS Reader,或者是RSS聚合
器)该页面提供RSS Feed以及该Feed的地址,这样,客户端程序可以直接反馈给用户提示用
户可以订阅的内容(例子:桌面或者基于浏览器的RSS Reader),或者自动聚合内容(例子
:RSS搜索引擎)。
Ok。 我用java实现这一功能。代码如下。。需要nekohtml-0.9.5.jar 和 xercesImple-2.6.2.jar
/**
* This function is Feed Autodiscovery, You just need passing the url, It would
* return the feeds.
*
* Rule, gets the elements "
* if true, get the href attribute.
*
* @param url the page url that need to discovery
* @return Feed list
*/
public static List
List
if (StringUtils.isBlank(url)){
return rt;
}
DOMParser parser = new DOMParser();
try {
parser.parse(url);
}catch(Exception e){
// ignore the exception; just return empty value;
return rt;
}
NodeList list = parser.getDocument().getElementsByTagName("link");
for(int i=0; i
发表评论
- 浏览: 220505 次
- 性别:

- 来自: 广州

- 详细资料
搜索本博客
我的相册
VB-seamless
共 13 张
共 13 张
最近加入圈子
最新评论
-
使用Terracotta和Tomcat建 ...
renavatior 写道"运行start.bat 9081 这样我们就启动了目 ...
-- by rainsf -
使用Terracotta和Tomcat建 ...
"运行start.bat 9081 这样我们就启动了目录9081中的tomcat ...
-- by renavatior -
广州3年多经验 5500的 ...
fucku 写道广州的软件厂家可比深圳多多了,不过比起北京上海来,还是少了很多, ...
-- by yongfan_420 -
广州3年多经验 5500的 ...
广州的软件厂家可比深圳多多了,不过比起北京上海来,还是少了很多,导致机会也没有这 ...
-- by fucku -
广州3年多经验 5500的 ...
想高工资就去厂家咯,老在集成商里面混能有多大个奔头
-- by fucku






评论排行榜