Skip to content

Instantly share code, notes, and snippets.

@vhogemann
Created October 19, 2024 13:33
Show Gist options
  • Save vhogemann/e698ebb0a136be8eeef7f877300c4726 to your computer and use it in GitHub Desktop.
Save vhogemann/e698ebb0a136be8eeef7f877300c4726 to your computer and use it in GitHub Desktop.
Shell script para baixar os relatórios de despesas com gastos parlamentares da Câmara de Deputados Federal do Brasil
#!/usr/bin/env sh
if [ ! -f "./legislaturas.json" ]; then
# downloads the file legislaturas.json
curl -s "https://dadosabertos.camara.leg.br/arquivos/legislaturas/json/legislaturas.json" > "./legislaturas.json"
fi
if [ ! -f "./deputados.json" ]; then
# downloads the file deputados.json
curl -s "https://dadosabertos.camara.leg.br/arquivos/deputados/json/deputados.json" > "./deputados.json"
fi
# from 2008 to current year
for year in $(seq 2008 $(date +"%Y")); do
# checks if file Ano-<year>.json already exists
if [ ! -f "./Ano-$year.json.zip" ]; then
# downloads the file Ano-<year>.json.zip
curl -s "https://www.camara.leg.br/cotas/Ano-$year.json.zip" > "./Ano-$year.json.zip"
# unzips the file Ano-<year>.json.zip
unzip -o "./Ano-$year.json.zip" -d "./"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment