Skip to content

Instantly share code, notes, and snippets.

@brianjriddle
Created March 23, 2010 10:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brianjriddle/341034 to your computer and use it in GitHub Desktop.
Save brianjriddle/341034 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'open-uri'
require 'json'
require 'nokogiri'
days = ['Måndag', 'Tisdag', 'Onsdag', 'Torsdag', 'Fredag']
week = []
doc = Nokogiri::HTML(open('http://www.recept.nu/veckomatsedel'))
doc.css('div.teaser-list.three-pack')[0..4].each_with_index do |div, i|
week[i] = {:day => days[i], :recipes => []}
div.css('li').each do |li|
week[i][:recipes] << {
:id => li.css('a').first[:href].match(/([0-9]{1})\.([0-9]+)/)[0],
:title => li.css('span').last.content[0..-5],
:thumbnail => li.css('img').first[:src]
}
end
end
puts week.to_json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment