Example of how to download a file from a url using python using mpython module urllib and urlretrieve function.
Table of contents
Using python 3
Let's take for example the file available on http://math.univ-toulouse.fr/~besse/Wikistat/pdf/st-intro.pdf:
>>> import urllib.request
>>> file_url = 'http://math.univ-toulouse.fr/~besse/Wikistat/pdf/st-intro.pdf'
>>> file_output_name = 'file_downloaded.pdf'
>>> urllib.request.urlretrieve(file_url, file_output_name)
Using python 2
Another example in python 2
>>> import urllib
>>> urllib.urlretrieve('http://math.univ-toulouse.fr/~besse/Wikistat/pdf/st-intro.pdf', "st-intro.pdf")
See also
Links | Tags |
---|---|
How to list and download all files from a url directory using python ? | Python; urlretrieve |
How to download a web pdf file from its url in python ? | Python; urlretrieve |