Last active
August 29, 2015 14:01
-
-
Save StephenFiser/9a31d29d09e0f8c70789 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 | |
| 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