概要とインストール

  1. RSSを読み書きするためのAPIです。
    • RSS 0.9x, RSS 1.0 / RDF, RSS 2.0, Atom 0.3 を解釈・出力することが出来ます。
    • OPML (RSSブックマーク) を解釈・出力することが出来ます。
    • Hibernateと連携してそれらをRDBに格納することが出来ます(よくわからないのでここではこの機能は使いません)
  2. http://informa.sourceforge.net/ からバイナリを取得し、添付されているJarファイルをクラスパスに通せばインストール完了

RSSの読み取り

  1. 特に難しいことはありません。RSS0.91/RSS1.0/RSS2.0/Atom0.3 共に読み込むことが出来ました。
    public class InformaExam {
      /**
       * RSSをInformaで取得するプログラム
       */
      public static void main(String[] args)
        throws IllegalAccessException, InvocationTargetException, 
          NoSuchMethodException {
        try {
          System.setProperty("http.proxyHost", "192.168.1.6");
          System.setProperty("http.proxyPort", "3128");
    
          // URL url = new URL("http://hondou.homedns.org/pukiwiki/pukiwiki.php?cmd=rss10"); //PukiWiki
          // URL url = new URL("http://manabekawori.cocolog-nifty.com/blog/index.rdf"); //RSS1.0
          // URL url = new URL("http://yamamura.exblog.jp/index.xml"); //RSS2.0 + image
          // URL url = new URL("http://www.cybridge.jp/index.rss"); //RSS0.91
          URL url = new URL("http://blog.hankyu-travel.com/mail_club/atom.xml"); // atom0.3
    
          ChannelIF channel = FeedParser.parse(new ChannelBuilder(), url);
          printObject(channel);
    
          ImageIF image = channel.getImage();
    
          if (image != null) {
            printObject(image);
          }
    
          Collection<ItemIF> items = channel.getItems();
    
          for (ItemIF item : items) {
            printObject(item);
          }
        } catch (IOException e) {
          e.printStackTrace();
        } catch (ParseException e) {
          e.printStackTrace();
        }
      }
    
      public static void printObject(final Object obj)
        throws IllegalAccessException, InvocationTargetException, 
          NoSuchMethodException {
        
        Map map = PropertyUtils.describe(obj);
    
        System.out.println(obj.getClass().getName() + "{");
    
        for (Iterator it = map.keySet().iterator(); it.hasNext();) {
          Object key = it.next();
          System.out.println("  " + key + "=" + map.get(key));
        }
    
        System.out.println("}");
      }
    }
  2. 読み込み結果(RSS0.91)
    RSS0.9xは、個々の記事(Item)に更新日付が無いことが特徴です。RSS文書全体(Channel)の更新日付までしか分かりません。
     2006/02/19 22:55:11 de.nava.informa.parsers.FeedParser parse
     情報: Channel uses RSS root element (Version 0.92).
     de.nava.informa.impl.basic.Channel{
       title=ニュース
       ttl=-1
       categories=[]
       publisher=null
       rating=null
       id=1025432386
       …(中略)…
       description=株式会社サイブリッジに関するお知らせ、パブリシティ、
       プレスリリースなどのニュース情報を配信
       lastBuildDate=Wed Feb 15 20:37:32 JST 2006
       updateFrequency=-1
       generator=null
       format=RSS 0.91
     }
     de.nava.informa.impl.basic.Item{
       comments=null
       enclosure=null
       title=フジテレビ スーパーニュースにて紹介されました
       class=class de.nava.informa.impl.basic.Item
       categories=[]
       link=http://www.cybridge.jp/news/?p=31
    !  date=null
       found=Sun Feb 19 22:55:11 JST 2006
       id=639342499
       creator=null
       description=フジテレビ スーパーニュースにて紹介されました。
      写真は放送前の取材陣さんたちです。
       guid=null
       subject=null
       unRead=true
       source=null
       channel=[Basic Channel (1025432386): ニュース (http://www.cybridge.jp/index.rss )]
     }
     de.nava.informa.impl.basic.Item{
       comments=null
       enclosure=null
       title=The Japan Timesにて弊社副社長の濱田が紹介されました
       class=class de.nava.informa.impl.basic.Item
  3. RSS1.0/2.0
    RSS1.0+Dublin Core と RSS2.0 はほぼ同じです。
    記事毎(Item)に更新日付があります。
     de.nava.informa.impl.basic.Channel{
       title=眞鍋かをりのココだけの話 powered by ココログ
       ttl=-1
       categories=[]
       publisher=null
       rating=null
       id=1037208528
       …(中略)…
       description=
       lastBuildDate=null
       updateFrequency=-1
       generator=http://www.typepad.com/?v=1.5.1j
       format=RSS 1.0
     }
     de.nava.informa.impl.basic.Item{
       comments=null
       enclosure=null
       title=眠れる森の○○
       class=class de.nava.informa.impl.basic.Item
       categories=[]
       link=http://manabekawori.cocolog-nifty.com/blog/2006/02/post_d157.html
    !  date=Wed Feb 15 22:58:42 JST 2006
       found=Sun Feb 19 23:28:27 JST 2006
       id=1847801781
       creator=かをり
       description=<p>「寝顔がひどいよね」 最近、久々に言われてしま
       ったの。このせりふ。 とういのもね...</p>
       guid=null
       subject=null
       unRead=true
       source=null
       channel=[Basic Channel (1037208528): 眞鍋かをりのココだけの話
       powered by ココログ (http://manabekawori.cocolog-nifty.com/blog/index.rdf )]
     }
     de.nava.informa.impl.basic.Item{
       comments=null
       enclosure=null
       title=誤爆祭り
       class=class de.nava.informa.impl.basic.Item
       categories=[]
       link=http://manabekawori.cocolog-nifty.com/blog/2006/02/post_3c2e.html
    !  date=Fri Feb 03 16:39:41 JST 2006
       found=Sun Feb 19 23:28:27 JST 2006
       id=1984445107
       creator=かをり
  4. image属性
    RSSにアイコンがあるときには、image属性がつきます。
     2006/02/19 23:03:18 de.nava.informa.parsers.FeedParser parse
     情報: Channel uses RSS root element (Version 2.0).
     de.nava.informa.impl.basic.Channel{
       title=エキサイト社長、山村幸広のインターネットブログ
       ttl=-1
       categories=[]
       publisher=null
       rating=null
       id=1365439855
       …(中略)…
       description=テーマは「仕事」「酒」「食」「健康」「趣味」です。
       lastBuildDate=null
       updateFrequency=-1
       generator=null
       format=RSS 2.0
     }
     de.nava.informa.impl.basic.Image{
       width=80
       height=107
       title=エキサイト社長、山村幸広のインターネットブログ
       class=class de.nava.informa.impl.basic.Image
       description=テーマは「仕事」「酒」「食」「健康」「趣味」です。
       link=http://yamamura.exblog.jp
       location=http://pds.exblog.jp/logo/1/200402/02/02/a000000220060203144829.jpg
       id=299676041
     }
     de.nava.informa.impl.basic.Item{
       comments=null
       enclosure=null
  5. Atom0.3
    Atomは、RSS0.9x/RSS1.0/RSS2.0とタグや構造が違いますが、InformaではRSSと同じオブジェクトの構造に解釈してくれます。
     2006/02/19 23:21:42 de.nava.informa.parsers.FeedParser parse
     情報: Channel uses feed root element (Version 0.3).
     de.nava.informa.impl.basic.Channel{
       title=阪急交通社メールマガジン
       ttl=-1
       categories=[]
       publisher=null
       rating=null
       id=546090499
       …(中略)…
       description=旅行のことなら阪急交通社におまかせ。
       海外旅行・国内旅行のご予約、格安航空券・国内宿泊施設の
       お問い合わせから観光情報まで、情報満載の阪急の総合旅行
       サイトです。
       lastBuildDate=null
       updateFrequency=-1
       generator=Movable Type
       format=Atom 0.3
     }
     de.nava.informa.impl.basic.Item{
       comments=null
       enclosure=null
       title=■往復JR特急利用の金沢フリープランが9,800円均一!…
       class=class de.nava.informa.impl.basic.Item
       categories=[]
       link=http://blog.hankyu-travel.com/mail_club/archives/2006/02/jr9800.html
       date=Thu Feb 16 00:02:00 JST 2006
       found=Sun Feb 19 23:21:42 JST 2006
       id=228144359
       creator=null
       description=編集長あっこです。朝起きて窓を開けた瞬間の空気に、
       心なしか春を感じるときがあります。暖かくなってくると、
       どこかに行きたい病がむくむくするのは私だけじゃないはず!
       神戸空港OPEN記念ツアーは、この春の旅にオススメですよ。
       guid=null
       subject=002_西日本版
       unRead=true
       source=null
       channel=[Basic Channel (546090499): 阪急交通社メールマガジン
       (http://blog.hankyu-travel.com/mail_club/atom.xml )]
     }
     de.nava.informa.impl.basic.Item{
       comments=null
       enclosure=null
       title=■今週のイチオシは「ハワイ」と「国内旅行・沖縄・大阪・九州・…
       class=class de.nava.informa.impl.basic.Item

OPMLの読み取り


Java


トップ   編集 凍結解除 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS   sitemap
Last-modified: 2006-03-14 (火) 00:54:53 (6619d)
Short-URL:
ISBN10
ISBN13
9784061426061