浏览代码

Put items in order by adding a time offset per item to each pubDate

master
Adrian Short 11 年前
父节点
当前提交
a26eb6c77b
共有 1 个文件被更改,包括 4 次插入1 次删除
  1. +4
    -1
      scrape.rb

+ 4
- 1
scrape.rb 查看文件

@@ -17,16 +17,19 @@ doc = Nokogiri.parse(open(url).read)

meeting = ''
items = []
items_this_meeting = 0

doc.at("#bodytext").children.each do |node|
if node.inner_text.match(/\d{1,2}\s+\w+\s+\d{4}/) # eg 10 December 2012
meeting = node.inner_text.strip
items_this_meeting = 0
end

node.children.each do |subnode|
if subnode.name == 'a' && subnode['href'].match(/\.mp3$/i)
items_this_meeting += 1
items << {
:d => Time.parse(meeting),
:d => Time.parse(meeting) + ((items_this_meeting - 1) * 30 * 60),
:href => subnode['href'].strip,
:title => subnode.inner_text.strip
}


正在加载...
取消
保存