Aemet
Crawls information from http://www.aemet.es
Extracted from http://para.glid.es source code.
Installation
Add this line to your application's Gemfile:
gem 'aemet'
And then execute:
$ bundle
Or install it yourself as:
$ gem install aemet
Usage
Extracts AEMET data url for city:
# Inialize the crawler
searcher = Aemet.search("A Coruña") # Aemet::Crawler.new("A Coruña")
# When initialized the crawler searchs for the city and initializes it.
searcher.aemet_id # => "15030"
# It provides an Aemet::City object
city = searcher.city # Aemet::City.new("15030")
# On the city XML url is constructed with `aemet_id`. Now this method is
# private, just to compare with previous versions.
city.send(:xml_url) # => http://www.aemet.es/xml/municipios/localidad_15030.xml
# Get current Weather data
city.weather # => { :prediccion => { :dia => { [ ...] }}
# Get the city page url (from xml response)
city.weather.origen.enlace # => http://www.aemet.es/es/eltiempo/prediccion/municipios/coruna-a-id15030
# The actual weather forecast
city.weather.prediccion.dia # => [ { "fecha" => "2013-03-23", "viento" => [] ...}, { "fecha" => ...} ]
If you have the city AEMET id stored in database you can initialize the city and even search for weather conidtions directly:
# Initialize a city with aemet_id
Aemet.city("15030")
# Get weather forecast based on aemet_id
Aemet.weather("15030")
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request