zM·éÌÍ^CgÆURLÌÝÅAt@NuïõÀèRecÅ é{��ÌzMÍs��ܹñB
http://perfume.yurufuwa.jp/blog_feeds/
�}ÌtB[hÍAI[v\[XÌCMSuRadiant CMSvÆARadiant CMSÌev[gãżÚRubyR[hðÀsÅ«éæ¤É·éGNXeVuBack DoorvðgÁÄ����µÄ��ܷB
http://www.radiantcms.org/
http://backdoor.rubyforge.org/
¡Ì��ê
- Radiant CMSªRSS[_[©çÌHTTPNGXgðó¯AY·éev[gÌðJnB
- Back DoorÉæèev[gàÌRubyR[hªÀs³êéBItBVuOÌHTMLðæ¾AKvÈîñðØèoµRSS����B
- Radiant CMSªï¿½ï¿½ï¿½ï¿½³ê½RSSðÔ·B
¡À
CAEguXML Feedsv�
Content-typeðutext/xmlvƵÄȺÌàeÌCAEgðì��µÜ·B
<r:content />
Xjybgutag_perfume_blog_feedvè`
ev[gÅuperfume_blog_feedvÆ��¤^OÅRSSð����ūéæ¤ÉµÜ·B^OÉ·éÌÍA¡ÌtB[hiÌÁ¿A©µä©A `¿áñAX^btÌeuOjð����·éÛÉRubyR[hðg��ñ¹éæ¤É·é½ßÅ·B
<r:tag name="perfume_blog_feed">
require 'rubygems'
require 'hpricot'
require 'rss'
require 'open-uri'
require 'cgi'
FETCH_URL = tag.attr['url']
FEED_TITLE = tag.attr['title']
FEED_LINK = tag.attr['url']
FEED_DESCRIPTION = tag.attr['title']
# wè³ê½URLÌRecðæ¾µAStringƵÄÔ·B
def get_html(url)
result = ''
open(url) {|f| result = f.read}
end
# HTML©çblogGg[Ì^CgAURLAXVútðæ¾µHashÌArrayƵÄÔ·B
#
# HashÌL[F :url => blogGgÌURL, :title => ^Cg, :date => XVút
def extract_blog_entries(html)
result = []
doc = Hpricot(html)
doc.search("div.box_cont_01").search('h4').search('a').each do |e|
url = CGI::unescape(e['href'].sub(/.*set_ref__=http%3a%2f%2f/, "http://")).gsub(/&sid=[^&]*/, "")
date = Time.parse(e.search('span').inner_html.gsub(/\./, "/"))
title = CGI::unescapeHTML(e.inner_html.gsub(/<span.*/, ''))
result.push({:url => url, :title => title, :date => date})
end
return result
end
# extract_blog_entriesÅß³ê½îñ©çtB[hð����·é
def generate_feed(blog_entries)
rss = RSS::Maker.make("2.0") do |maker|
maker.channel.title = FEED_TITLE
maker.channel.link = FEED_LINK
maker.channel.description = FEED_DESCRIPTION
blog_entries.each do |entry|
item = maker.items.new_item
item.title = entry[:title]
item.link = entry[:url]
item.date = entry[:date]
item.dc_date = entry[:date]
end
end
result = rss.to_s
end
html = get_html(FETCH_URL)
if html != nil then
blog_entries = extract_blog_entries(html)
xml = generate_feed(blog_entries)
end
xml
</r:tag>
RSSoÍpev[gì��
ȺÌàeÌev[gðì��µÜ·BºLÍ `¿áñÌuO(http://www.amuse.co.jp/perfume/blog/a-chan/)ÌtB[hÌáÅ·B
<r:snippet name="tag_perfume_blog_feed" /><r:perfume_blog_feed url="http://www.amuse.co.jp/perfume/blog/a-chan/" title="Perfume A-CHAN BLOG" />
ev[gÌuslugvÍRSSÁÛua-chan.xmlvÈÇƵܷBCAEgÍAOqÌèÅì��µ½uXML FeedsvðKpµÜ·B
ÈãÅ®¹Å·B
Radiant CMSÅÍêèÔRecªLbV ³êÜ·BLbV ªLøÅ éÔÍA½xANZXµÄàÀÛÉÍtB[h����Ísíê¸LbV ªgp³êÜ·BHTMLæ¾æÌT[oÖÌ�~ªy¸³êéÌÅDsÅ·B
Radiant CMSÅX|XLbV ÌLøúÀðÏX·é:
http://vividtone.seesaa.net/article/94905361.html