Created
May 23, 2014 00:09
-
-
Save StephenFiser/bdfd26937abe7763df15 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 'open-uri' | |
print "Enter a website domain you like (without the http://): " | |
website = gets.chomp | |
if website.count(".") >= 2 | |
first_letter = website.index(".") + 1 # we want the letter just after the first dot | |
after_first_letter = first_letter + 1 | |
last_letter = (website.index(".", after_first_letter) - 1) | |
website_title = website[first_letter..last_letter] | |
elsif website.count(".") == 1 | |
website_title = website[0..(website.index(".") - 1)] | |
else | |
website_title = nil | |
end | |
unless website_title.nil? | |
file = open("http://#{website}") | |
contents = file.read | |
out_file = File.new("#{website_title}.html", "w") | |
out_file.puts contents | |
out_file.close | |
else | |
puts "We aren't sure what you did. Try again..." | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment