Skip to content

Instantly share code, notes, and snippets.

@theist
Last active August 29, 2015 14:17
Show Gist options
  • Save theist/a1d462cc0b72ecebc992 to your computer and use it in GitHub Desktop.
Save theist/a1d462cc0b72ecebc992 to your computer and use it in GitHub Desktop.
Commandline andalucia's realtime results
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