Skip to content

Instantly share code, notes, and snippets.

@dpick
Created January 31, 2013 02:06
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 dpick/4679320 to your computer and use it in GitHub Desktop.
Save dpick/4679320 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'nokogiri'
require 'open-uri'
doc = Nokogiri::HTML(open(ARGV[0]))
title = doc.css('title').first.content.scan(/\r\n\t(.*) -/).first
puts title
image = doc.css('img#imgPhoto').first.attributes['src'].value
image_title = doc.css('img#imgPhoto').first.attributes['title'].value
ingredients = doc.css('#liIngredient').map { |e| e.content.strip.gsub(/\r\n +/, ' ') }
directions = doc.css('.directLeft li').map { |e| e.content }
puts "### Source"
puts "[AllRecipes](#{ARGV[0]})"
puts ""
puts '### Ingredients'
ingredients.each do |ingredient|
puts "* #{ingredient}"
end
puts ""
puts "### Directions"
directions.each do |direction|
puts "* #{direction}"
end
puts ''
puts "### Pictures"
puts "![#{image_title}](#{image})"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment