@@ -26,10 +26,10 @@ \section{\module{urllib} ---
2626if the server returns an error code, the \exception {IOError} exception
2727is raised. If all went well, a file-like object is returned. This
2828supports the following methods: \method {read()}, \method {readline()},
29- \method {readlines()}, \method {fileno()}, \method {close()} and
30- \method {info()}.
29+ \method {readlines()}, \method {fileno()}, \method {close()},
30+ \method {info()} and \method {geturl()} .
3131
32- Except for the \method {info()} method,
32+ Except for the \method {info()} and \ method{geturl()} methods ,
3333these methods have the same interface as for
3434file objects --- see section \ref {bltin-file-objects } in this
3535manual. (It is not a built-in file object, however, so it can't be
@@ -47,7 +47,14 @@ \section{\module{urllib} ---
4747a Date representing the file's last-modified time, a Content-Length
4848giving file size, and a Content-Type containing a guess at the file's
4949type. See also the description of the
50- \module {mimetools}\refstmodindex {mimetools} module.
50+ \refmodule {mimetools}\refstmodindex {mimetools} module.
51+
52+ The \method {geturl()} method returns the real URL of the page. In
53+ some cases, the HTTP server redirects a client to another URL. The
54+ \function {urlopen()} function handles this transparently, but in some
55+ cases the caller needs to know which URL the client was redirected
56+ to. The \method {geturl()} method can be used to get at this
57+ redirected URL.
5158
5259If the \var {url} uses the \file {http:} scheme identifier, the optional
5360\var {data} argument may be given to specify a \code {POST} request
@@ -57,7 +64,7 @@ \section{\module{urllib} ---
5764
5865\end {funcdesc }
5966
60- \begin {funcdesc }{urlretrieve}{url\optional {, filename} \optional {, hook}}
67+ \begin {funcdesc }{urlretrieve}{url\optional {, filename\optional {, hook} }}
6168Copy a network object denoted by a URL to a local file, if necessary.
6269If the URL points to a local file, or a valid cached copy of the
6370object exists, the object is not copied. Return a tuple
@@ -154,19 +161,17 @@ \section{\module{urllib} ---
154161\item
155162The data returned by \function {urlopen()} or \function {urlretrieve()}
156163is the raw data returned by the server. This may be binary data
157- (e.g. an image), plain text or (for example) HTML. The HTTP protocol
158- provides type information in the reply header, which can be inspected
159- by looking at the \code {content-type} header. For the Gopher protocol,
160- type information is encoded in the URL; there is currently no easy way
161- to extract it. If the returned data is HTML, you can use the module
162- \module {htmllib}\refstmodindex {htmllib} to parse it.
163- \index {HTML}
164- \indexii {HTTP}{protocol}
165- \indexii {Gopher}{protocol}
164+ (e.g. an image), plain text or (for example) HTML\index {HTML}. The
165+ HTTP\indexii {HTTP}{protocol} protocol provides type information in the
166+ reply header, which can be inspected by looking at the
167+ \code {content-type} header. For the Gopher\indexii {Gopher}{protocol}
168+ protocol, type information is encoded in the URL; there is currently
169+ no easy way to extract it. If the returned data is HTML, you can use
170+ the module \refmodule {htmllib}\refstmodindex {htmllib} to parse it.
166171
167172\item
168173Although the \module {urllib} module contains (undocumented) routines
169174to parse and unparse URL strings, the recommended interface for URL
170- manipulation is in module \module {urlparse}\refstmodindex {urlparse}.
175+ manipulation is in module \refmodule {urlparse}\refstmodindex {urlparse}.
171176
172177\end {itemize }
0 commit comments