Skip to content

Instantly share code, notes, and snippets.

@StephenFiser
Last active August 29, 2015 14:01
Show Gist options
  • Select an option

  • Save StephenFiser/9a31d29d09e0f8c70789 to your computer and use it in GitHub Desktop.

Select an option

Save StephenFiser/9a31d29d09e0f8c70789 to your computer and use it in GitHub Desktop.
require 'open-uri'
print "Enter a website domain you like (without the http://): "
website = gets.chomp
begin
file = open("http://#{website}")
contents = file.read
unless contents.index("<h1>").nil?
header_start = contents.index("<h1>") + 4
header_end = contents.index("</h1>") - 1
p contents[header_start..header_end]
else
p "There were no h1 tags on #{website}."
end
rescue
puts "You typed in something wrong. Please try again."
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment