Skip to content

Instantly share code, notes, and snippets.

@coderforhire
Created May 11, 2012 18:50
Show Gist options
  • Save coderforhire/2661655 to your computer and use it in GitHub Desktop.
Save coderforhire/2661655 to your computer and use it in GitHub Desktop.
desc "Fetch weather"
task :fetch_weather => :environment do
require 'nokogiri'
require 'open-uri'
@weathers = Weather.all
@weathers.each do |weather|
url = "http://kitchen.screenfeed.com/weather/both/dJlC_W1LY0-DukSjsfJV1w.xml?location=#{weather.zip}"
puts url
doc = Nokogiri::XML(open(url))
doc.xpath("/WeatherData/WeatherData/humidity")
weather.update_attribute(:humidity, humidity)
puts doc
end
end
~
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment