Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save varellalexandre/bbf1febd634c5ce53793c8f3995ce0ec to your computer and use it in GitHub Desktop.

Select an option

Save varellalexandre/bbf1febd634c5ce53793c8f3995ce0ec to your computer and use it in GitHub Desktop.
Baixa arquivo do portal da transparência
def file_download(ano, output_path):
headers = {
'Accept-Encoding':"gzip, deflate, br",
'Accept':"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
'Sec-Fetch-Mode':'navigate',
'User-Agent':"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36"
}
file_response = requests.get(f'https://portaldatransparencia.gov.br/download-de-dados/viagens/{ano}',headers= headers)
file_content = open(f'{output_path}','wb')
file_content.write(file_response.content)
file_content.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment