Issue10050 - urlretrieve uses newer urlopen. reporthook of urlretrieve takes, block number, block read size, file_size

This commit is contained in:
Senthil Kumaran 2012-03-13 19:29:33 -07:00
parent a2251aadaa
commit e24f96a059
5 changed files with 119 additions and 42 deletions

View file

@ -56,6 +56,13 @@ The simplest way to use urllib.request is as follows::
response = urllib.request.urlopen('http://python.org/')
html = response.read()
If you wish to retrieve a resource via URL and store it in a temporary location,
you can do so via the :func:`urlretrieve` function::
import urllib.request
local_filename, headers = urllib.request.urlretrieve('http://python.org/')
html = open(local_filename)
Many uses of urllib will be that simple (note that instead of an 'http:' URL we
could have used an URL starting with 'ftp:', 'file:', etc.). However, it's the
purpose of this tutorial to explain the more complicated cases, concentrating on