Revisions

gist: 149258 Download_button fork
public
Public Clone URL: git://gist.github.com/149258.git
Embed All Files: show embed
Ruby #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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'