RSS4j 0.92
- ライブラリのインストール
以下のサイトよりライブラリをダウンロード。
http://www.churchillobjects.com/c/13005.html
# cd /usr/local/arch # wget http://www.churchillobjects.com/soft/rss4j/rss4j092.jar # cd ../src # jar xvf ../arch/rss4j092.jar # cp rss4j092/lib/rss4j.jar /home/test/WEB-INF/lib # cd /home/test/src/com/domain/test # vi RssTest.java
- サンプルソース
package com.domain.test;
import java.net.URL;
import java.util.Enumeration;
import churchillobjects.rss4j.RssChannel;
import churchillobjects.rss4j.RssChannelItem;
import churchillobjects.rss4j.RssDocument;
import churchillobjects.rss4j.parser.RssParser;
public class RssTest{
public static void main(String args[])
throws Exception{
String url=null;
try{
if(args[0]!=null)url=args[0];
URL u=new URL(url);
RssDocument rss=RssParser.parseRss(u.openConnection().getInputStream());
Enumeration e=rss.channels();
while(e.hasMoreElements()){
RssChannel rc=(RssChannel)e.nextElement();
Enumeration items=rc.items();
System.out.println(rc.getChannelTitle());
System.out.println(rc.getChannelLink());
System.out.println(rc.getChannelDescription());
while(items.hasMoreElements()){
RssChannelItem item=(RssChannelItem)items.nextElement();
System.out.println(item.getItemTitle());
System.out.println(item.getItemLink());
System.out.println(item.getItemDescription());
}
}
}
catch(Exception e){
e.printStackTrace();
}
}
}# java com.domain.test.RssTest \ > http://news.goo.ne.jp/news/rss/topics/chumoku/index.rdf
Counter: 638,
today: 1,
yesterday: 3
最終更新: 2008-11-26 (水) 02:07:46 (JST) (1272d) by aqua
