Created
October 3, 2023 22:33
-
-
Save varellalexandre/bbf1febd634c5ce53793c8f3995ce0ec to your computer and use it in GitHub Desktop.
Baixa arquivo do portal da transparência
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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