summaryrefslogtreecommitdiffstats
path: root/Doc/howto
diff options
context:
space:
mode:
authorSenthil Kumaran <senthil@uthcode.com>2012-03-14 02:29:33 (GMT)
committerSenthil Kumaran <senthil@uthcode.com>2012-03-14 02:29:33 (GMT)
commite24f96a05973ddbb59d88c03570aef8545c5ef10 (patch)
treec3c8721fe8e2bf99cf6bb2c6761ad14adc88eb48 /Doc/howto
parenta2251aadaa6de54eaf9663451afd16806a0712f3 (diff)
downloadcpython-e24f96a05973ddbb59d88c03570aef8545c5ef10.zip
cpython-e24f96a05973ddbb59d88c03570aef8545c5ef10.tar.gz
cpython-e24f96a05973ddbb59d88c03570aef8545c5ef10.tar.bz2
Issue10050 - urlretrieve uses newer urlopen. reporthook of urlretrieve takes, block number, block read size, file_size
Diffstat (limited to 'Doc/howto')
-rw-r--r--Doc/howto/urllib2.rst7
1 files changed, 7 insertions, 0 deletions
diff --git a/Doc/howto/urllib2.rst b/Doc/howto/urllib2.rst
index 76286bd..058cf96 100644
--- a/Doc/howto/urllib2.rst
+++ b/Doc/howto/urllib2.rst
@@ -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