Created
July 3, 2011 20:38
-
-
Save vertexclique/1062582 to your computer and use it in GitHub Desktop.
Site Sucker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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