Created
May 10, 2012 02:49
-
-
Save dpick/2650677 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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