mirror of
https://github.com/python/cpython.git
synced 2025-07-29 06:05:00 +00:00
Issue10050 - urlretrieve uses newer urlopen. reporthook of urlretrieve takes, block number, block read size, file_size
This commit is contained in:
parent
a2251aadaa
commit
e24f96a059
5 changed files with 119 additions and 42 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue