Pārlūkot izejas kodu

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

master
Adrian Short pirms 12 gadiem
vecāks
revīzija
a26eb6c77b
1 mainītis faili ar 4 papildinājumiem un 1 dzēšanām
  1. +4
    -1
      scrape.rb

+ 4
- 1
scrape.rb Parādīt failu

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


Notiek ielāde…
Atcelt
Saglabāt