All pastes #332520 Raw Edit

Unnamed

public ruby v1 · immutable
#332520 ·published 2007-01-30 01:32 UTC
rendered paste body
#!/usr/bin/rubyrequire 'net/http'require 'xmlsimple'RSS_FEED_URL_LONDON = 'http://xml.weather.yahoo.com/forecastrss?p=CAXX0114&u=c'RSS_FEED_URL_COLLINGWOOD = 'http://xml.weather.yahoo.com/forecastrss?p=CAXX0090&u=c'begin    text_london = Net::HTTP.get(URI.parse(RSS_FEED_URL_LONDON))    text_collingwood = Net::HTTP.get(URI.parse(RSS_FEED_URL_COLLINGWOOD))rescue    puts "ERROR: Failed fetching RSS feed!"    exitendbegin    xml_london = XmlSimple.xml_in(text_london)    channel_london = xml_london['channel'][0]    xml_collingwood = XmlSimple.xml_in(text_collingwood)    channel_collingwood = xml_collingwood['channel'][0]rescue    puts "Error: Could not parse the XML!"    exitendtemp_units = channel_london['units'][0]['temperature']puts "weather"puts "  location   london @ " + channel_london['lastBuildDate'][0].sub(/..., \d\d ... \d\d\d\d /,'').downcaseputs "    temp     " + channel_london['item'][0]['condition'][0]['temp'] + temp_units.downcaseputs "    cond     " + channel_london['item'][0]['condition'][0]['text'].downcaseputs "  location   collingwood @ " + channel_collingwood['lastBuildDate'][0].sub(/..., \d\d ... \d\d\d\d /,'').downcaseputs "    temp     " + channel_collingwood['item'][0]['condition'][0]['temp'] + temp_units.downcaseputs "    cond     " + channel_collingwood['item'][0]['condition'][0]['text'].downcase