How to download a file with Python?

Asked

Viewed 2,315 times

0

This site has several links that open Pdfs, in the locations of "Entire content": http://www.camara.gov.br/proposicoesWeb/prop_emendas?idProposicao=2122076&subst=0

In Python 3 I wrote this code to try to download a link:

import urllib.request, urllib.parse, urllib.error
url = "http://www.camara.gov.br/proposicoesWeb/prop_emendas?idProposicao=2122076&subst=0"
urllib.request.urlretrieve(url, "EMC 1-2017 PL678716 =- PL 6787-2016.pdf")

This message appears in Jupyter:

('EMC 1-2017 PL678716 =- PL 6787-2016.pdf', ) )

You have downloaded a PDF file but it does not open in Acrobat: you could not open the file because there is no support for that file type or it was damaged

Please someone knows how to download correctly?

  • Can you tell if the function urlretrieve considers the entire HTTP response obtained from the URL?

  • I can’t tell if you consider

  • I was able to solve: https://github.com/reichaves/reftrab/blob/master/chupaemenda.ipynb

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.