Skip to content

Instantly share code, notes, and snippets.

@vertexclique
Created July 3, 2011 20:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vertexclique/1062582 to your computer and use it in GitHub Desktop.
Save vertexclique/1062582 to your computer and use it in GitHub Desktop.
Site Sucker
require 'net/http'
puts "Enter the site adress you want to suck:
Note that, directory must be specified
For example: http://regularlambda.github.com/blabla
or simply http://regularlambda.github.com/"
a = gets
url = URI.parse(a.chomp!)
response = Net::HTTP.start(url.host, url.port) do |http|
http.get(url.path)
end
content = response.body
path = Dir.pwd + "/emittedbody.html"
if(FileTest.exist?(path) == true)
puts "Cannot retrieved. File exists."
puts "Would you like to overwrite? (y/n)"
ans = gets
if(ans.chomp! == 'y')
new = File.open(path, 'w'){|f| f.write(content)}
else
p "Script exited with code 'nil'"
end
else
new = File.open(path, 'w') { |f| f.write(content) }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment