Skip to content

Instantly share code, notes, and snippets.

@GuillaumeDesforges
Created April 10, 2022 21:08
Show Gist options
  • Save GuillaumeDesforges/3bcc98ae1a70d918cdd2e486d4e099c4 to your computer and use it in GitHub Desktop.
Save GuillaumeDesforges/3bcc98ae1a70d918cdd2e486d4e099c4 to your computer and use it in GitHub Desktop.
curl -s 'https://graphics.afpforum.com/data/presidential-fr-2022-live-constantes/communes_codes.json' | jq -c '.[]' \
| while read commune_dict
do
code=$(echo "$commune_dict" | jq -r '.c')
nom=$(echo "$commune_dict" | jq -r '.n')
curl -sq "https://graphics.afpforum.com/data/presidential-fr-2022-live-results/resultats1/communes/IR1_$code.json" \
| jq --arg code "$code" -c '.lesResultats | map({key: .individuNom, value: .resPourCent}) | from_entries | . + {code: $code}' \
>> "resultats.json"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment