I need to download a file from one of those links with python, but the pdf won’t open after downloaded.
https://fnet.bmfbovespa.com.br/fnet/publico/exibirDocumento?id=693676
https://fnet.bmfbovespa.com.br/fnet/publico/downloadDocumento?id=693676
import requests
i = ["https://fnet.bmfbovespa.com.br/fnet/publico/exibirDocumento?id=693676", "https://fnet.bmfbovespa.com.br/fnet/publico/downloadDocumento?id=693676"]
l =0
for k in i:
l += 1
user_agent = "scrapping_script/1.0"
headers = {'User-Agent': user_agent}
download = requests.get(k, headers=headers)
with open(f"/Users/renato/Documents/{l}.pdf", 'wb') as f:
f.write(download.content)
I already tried using urllib and changing the headers, but had the same issue. Any suggestions? Thanks!