Browse Source

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

master
Adrian Short 11 years ago
parent
commit
a26eb6c77b
1 changed files with 4 additions and 1 deletions
  1. +4
    -1
      scrape.rb

+ 4
- 1
scrape.rb View File

@@ -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
}


Loading…
Cancel
Save