Last active
August 29, 2015 14:17
-
-
Save theist/a1d462cc0b72ecebc992 to your computer and use it in GitHub Desktop.
Commandline andalucia's realtime results
This file contains 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 'json' | |
require 'rest-client' | |
participacion_url = 'http://resultados-elecciones.rtve.es/andalucia/multimedia/json/2015/participacion/andalucia/2015-participacion-andalucia.json' | |
partidos_url = 'http://resultados-elecciones.rtve.es/andalucia/multimedia/json/2015/resultados/andalucia/2015-resultados-andalucia.json' | |
partidos = JSON.parse(RestClient.get(partidos_url)) | |
participacion = JSON.parse(RestClient.get(participacion_url)) | |
%w(escrutado_porcentaje en_blanco_porcentaje abstencion_porcentaje nulos_porcentaje).each do |data| | |
puts "#{data}: #{participacion[data]}%" | |
end | |
partidos['resultados']['partidos'].each do |p| | |
if p['escanos'] > 0 | |
puts "#{p['siglas']}: #{p['escanos']} escanos" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment