Skip to content

Instantly share code, notes, and snippets.

View varellalexandre's full-sized avatar
😀
@127.0.0.1

varellalexandre varellalexandre

😀
@127.0.0.1
View GitHub Profile
@varellalexandre
varellalexandre / gist:bbf1febd634c5ce53793c8f3995ce0ec
Created October 3, 2023 22:33
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)
@varellalexandre
varellalexandre / helps.py
Created December 5, 2020 06:31
helps.py
def status(medicoes:list)->int:
assert len(medicoes) >= 2
if medicoes[-1] > medicoes[-2]:
return 1
elif medicoes[-1] < medicoes[-2]:
return -1
else:
return 0