Skip to content

Instantly share code, notes, and snippets.

@cogumm
Created September 25, 2012 23:15
Show Gist options
  • Save cogumm/3785020 to your computer and use it in GitHub Desktop.
Save cogumm/3785020 to your computer and use it in GitHub Desktop.
Feed de imagens
require 'rubygems'
require 'sinatra'
require 'hpricot'
require 'open-uri'
html = '<html><head><title>Feed de imagens</title>'
html += '<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"></meta></head>'
html += '<link rel="stylesheet" href="http://passets-lt.pinterest.com/css/pinboard_759c5bb3.css" type="text/css" media="all"/>'
html += '<body><h1>Feed de imagens</h1>'
doc = Hpricot open('http://pinterest.com/cogumm/nerd/')
doc.search 'img' do |img|
img['src'] = "#{img['src']}"# unless img['src'].include?('submarino.com.br')
html += img.to_s
end
html += '</body></html>'
File.open('Imagens.html', 'w') { |file| file << html }
# system 'explorer Imagens.html'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment