Skip to content

Instantly share code, notes, and snippets.

@19WAS85
Created July 17, 2009 20:21
Show Gist options
  • Save 19WAS85/149258 to your computer and use it in GitHub Desktop.
Save 19WAS85/149258 to your computer and use it in GitHub Desktop.
require 'hpricot'
require 'open-uri'
html = '<html><head><title>Agora no Globo.com</title>'
html += '<META http-equiv="Content-Type" content="text/html;charset=UTF-8"></head>'
html += '<body><h1>Agora</h1><h2>no Globo.com</h2>'
doc = Hpricot open('http://www.globo.com')
doc.search 'img' do |img|
img['src'] = "http://www.globo.com#{img['src']}" unless img['src'].include?('globo.com')
html += img.to_s
end
html += '</body></html>'
File.open('Agora.html', 'w') { |file| file << html }
# system 'explorer Agora.html'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment