Skip to content

Commit 94a8aea

Browse files
committed
fix yahoo weather
1 parent 35bc006 commit 94a8aea

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

processing_app/topics/advanced_data/yahoo_weather.rb

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,21 @@
77
#
88

99
attr_reader :zip, :weather, :temperature
10-
10+
WOEID = '12761335' # yahoos code for ZIP = '10003'
1111
def setup
1212
sketch_title 'Yahoo Weather'
1313
@zip = 10_003
1414
font = create_font('Times Roman', 26)
1515
# font = create_font('Merriweather-Light.ttf', 28)
1616
text_font(font)
1717
# The URL for the XML document
18-
url = format('http://xml.weather.yahoo.com/forecastrss?p=%s', zip)
18+
19+
fo = "http://query.yahooapis.com/v1/public/yql?format=xml&q=select+*+from+weather.forecast+where+woeid=%s+and+u='F'"
20+
url = format(fo, WOEID)
1921
# Load the XML document
2022
xml = loadXML(url)
2123
# Grab the element we want
22-
forecast = xml.get_child('channel')
23-
.get_child('item')
24-
.get_child('yweather:forecast')
24+
forecast = xml.getChild("results/channel/item/yweather:forecast");
2525
# Get the attributes we want
2626
@temperature = forecast.get_int('high')
2727
@weather = forecast.get_string('text')
@@ -39,4 +39,3 @@ def draw
3939
def settings
4040
size 600, 360, FX2D
4141
end
42-

0 commit comments

Comments
 (0)