How to download a web pdf file from a url in python ?

To download a pdf from a given web url using python, a solution is to use the module urllib. Lets try to download the file available from the following url

using urlretrieve:

>>> import urllib
>>> urllib.urlretrieve('', "st-intro.pdf")

Note: it is also possible to directly change the name of the file (we can called it new_file.pdf for instance):

>>> urllib.urlretrieve('', "new_file.pdf")

See also