Last active
August 29, 2015 14:18
-
-
Save asterite/6b68322fbf50c1a4bc86 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 "http/client" | |
def title(x) | |
url = "http://www.wunderground.com/cgi-bin/findweather/hdfForecast?query=#{x}" | |
tag = "<meta property=\"og:title\" content=\"" | |
response = HTTP::Client.get(url).body | |
title1 = response.index(tag).not_nil! | |
title2 = response.index("\" />", title1).not_nil! - 1 | |
result = response[(title1 + tag.length)..title2] | |
result = result.gsub /°/, "°F" | |
result | |
end | |
puts title(19610) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment