Skip to content

Instantly share code, notes, and snippets.

@abadongutierrez
Created June 3, 2024 06:12
Show Gist options
  • Save abadongutierrez/e5cd2a648b04030eaf1af526d9d06abb to your computer and use it in GitHub Desktop.
Save abadongutierrez/e5cd2a648b04030eaf1af526d9d06abb to your computer and use it in GitHub Desktop.
#!/bin/bash
URL="https://prep2024.ine.mx/publicacion/nacional/assets/presidencia/presidenciaNacional.json"
fetch_and_print() {
echo "------------------------------------------------------------------------------------"
JSON_FILE="presidenciaNacional_$(date +%Y-%m-%d_%H-%M-%S).json"
curl --compressed -o "$JSON_FILE" "$URL"
if [ $? -ne 0 ]; then
echo "Error"
return 1
fi
echo "Resultados hasta el momento..."
jq '.votosDistritos.votos[] | "Candidato: \(.candidatoPropietario), Porcentaje: \(.porcentajeProporcional)"' "$JSON_FILE"
}
while true; do
fetch_and_print
# wait 5 minutes
WAIT_TIME=$((60 * 5))
sleep $WAIT_TIME
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment