feedを全文取得するプラグイン(できたことにする)

## zenbun.rb
## feed zenbun kakutoku
#
# config.yaml(example)
#- module: load_rss
#  config:
#    url: http://ameblo.jp/satoeritimes/rss20.xml
#- module: zenbun
#  config:
#    domclass: div.contents
#- module: save_rss
#  config:
#    filename: satoeri.rdf
#    title: statoeritimes.zenbun
#    link:  http://ameblo.jp/satoeritimes/
#
require 'rubygems'
require 'hpricot'

def get_defaut_domclass(uri)
   return "div.main"       if uri =~ /livedoor/
   return "div.body"       if uri =~ /http:\/\/d\.hatena\.ne\.jp/
   return "div.contents"   if uri =~ /http:\/\/ameblo\.jp/
   return "div.entry-body" if uri =~ /-nifty/
   "div.contents"
end

def get_zenbun(uri, domclass)
   domclass = get_defaut_domclass(uri) unless domclass
   doc = Hpricot(open(uri))
   elem = doc.search(domclass) # get contents
   elem.inner_html             # retrun contents
end

def zenbun(config, data)
   data.each do |element|
      next unless element.link
      element.description = NKF.nkf('-w',get_zenbun(element.link,config['domclass']) )
      element.content_encoded = element.description.dup if element.respond_to?(:content_encoded)
   end
end

config:
domclass:

に適当なことを書いてくれるとそのクラスを持ってきてくれます。
これをcronでまわしてfeedを作っていろいろして、快適れす。

完成度が低くてアレですが、スクリプトの再利用をしたい方はご自由に。