Skip to content

Instantly share code, notes, and snippets.

@jshawl
Last active August 29, 2015 14:02
Show Gist options
  • Save jshawl/edd0113c495e820441b7 to your computer and use it in GitHub Desktop.
Save jshawl/edd0113c495e820441b7 to your computer and use it in GitHub Desktop.
require 'open-uri'
require 'nokogiri'
link = "http://entrenchant.blogspot.ch/2012/02/web-page-mirroring-wget-in-ruby.html?m=1"
now = Time.now.to_i.to_s
@doc = Nokogiri::HTML(open( link ))
@css_tags = @doc.css('[rel="stylesheet"]').map { |l| URI.join( link, l['href'] ).to_s }
# open temp file for writing
file = File.open( now + '.css','w') { | f |
@css_tags.each do | c |
contents = open(c).read
f.write( contents )
end
}
hash = Digest::MD5.hexdigest(File.read(now+'.css'))
p hash
File.rename(now+'.css', hash+".css")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment