Skip to content

Instantly share code, notes, and snippets.

@dpick
Created May 10, 2012 02:49
Show Gist options
  • Save dpick/2650677 to your computer and use it in GitHub Desktop.
Save dpick/2650677 to your computer and use it in GitHub Desktop.
puts "Adding #{size = feed.entries.size} entries"
feed.entries.each { |entry| title_to_entries[entry.title] = entry }
start += size
end
ignored_phrases = ["View my other apartments", "American Realty Pros"]
title_to_entries.reject! do |title, entry|
ignored_phrases.any? { |phrase| entry.summary.include?(phrase) }
end
image_hashes = []
title_to_entries.each do |title, entry|
entry = Nokogiri::HTML(entry.summary)
images = entry.css('img').map { |element| element['src'] }
images.each_with_index do |image, index|
begin
open(image) do |f|
File.open("whatever_file_#{index}.jpg","w") do |file|
image_hashes << Digest::SHA1.hexdigest(f.read)
end
end
rescue
puts "error reading image"
end
end
end
p image_hashes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment