Mercurial > cpython-lru_cache-weakref
annotate Doc/lib/liburlparse.tex @ 6719:faebc1940432 legacy-trunk
Understand -Xlinker option.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Tue, 02 Dec 1997 20:38:11 +0000 |
| parents | 3468ea8645ca |
| children | 10f2921a091e |
| rev | line source |
|---|---|
|
2576
f47bc5554418
mass changes; fix titles; add examples; correct typos; clarifications;
Guido van Rossum <guido@python.org>
parents:
2453
diff
changeset
|
1 \section{Standard Module \sectcode{urlparse}} |
| 5818 | 2 \label{module-urlparse} |
| 2449 | 3 \stmodindex{urlparse} |
| 4 \index{WWW} | |
|
2576
f47bc5554418
mass changes; fix titles; add examples; correct typos; clarifications;
Guido van Rossum <guido@python.org>
parents:
2453
diff
changeset
|
5 \index{World-Wide Web} |
| 2449 | 6 \index{URL} |
| 7 \indexii{URL}{parsing} | |
| 8 \indexii{relative}{URL} | |
| 9 | |
|
2453
cdd3a721b40e
a few typographical changes (e.g. -- => ---) and lots of new stuff in the WWW chapter
Guido van Rossum <guido@python.org>
parents:
2449
diff
changeset
|
10 \renewcommand{\indexsubitem}{(in module urlparse)} |
|
cdd3a721b40e
a few typographical changes (e.g. -- => ---) and lots of new stuff in the WWW chapter
Guido van Rossum <guido@python.org>
parents:
2449
diff
changeset
|
11 |
| 2449 | 12 This module defines a standard interface to break URL strings up in |
| 13 components (addessing scheme, network location, path etc.), to combine | |
| 14 the components back into a URL string, and to convert a ``relative | |
| 15 URL'' to an absolute URL given a ``base URL''. | |
| 16 | |
| 17 The module has been designed to match the current Internet draft on | |
| 18 Relative Uniform Resource Locators (and discovered a bug in an earlier | |
| 19 draft!). | |
| 20 | |
| 21 It defines the following functions: | |
| 22 | |
| 23 \begin{funcdesc}{urlparse}{urlstring\optional{\, | |
| 24 default_scheme\optional{\, allow_fragments}}} | |
| 25 Parse a URL into 6 components, returning a 6-tuple: (addressing | |
| 26 scheme, network location, path, parameters, query, fragment | |
| 27 identifier). This corresponds to the general structure of a URL: | |
| 28 \code{\var{scheme}://\var{netloc}/\var{path};\var{parameters}?\var{query}\#\var{fragment}}. | |
| 29 Each tuple item is a string, possibly empty. | |
| 30 The components are not broken up in smaller parts (e.g. the network | |
| 31 location is a single string), and \% escapes are not expanded. | |
|
2576
f47bc5554418
mass changes; fix titles; add examples; correct typos; clarifications;
Guido van Rossum <guido@python.org>
parents:
2453
diff
changeset
|
32 The delimiters as shown above are not part of the tuple items, |
|
f47bc5554418
mass changes; fix titles; add examples; correct typos; clarifications;
Guido van Rossum <guido@python.org>
parents:
2453
diff
changeset
|
33 except for a leading slash in the \var{path} component, which is |
|
f47bc5554418
mass changes; fix titles; add examples; correct typos; clarifications;
Guido van Rossum <guido@python.org>
parents:
2453
diff
changeset
|
34 retained if present. |
| 2449 | 35 |
| 36 Example: | |
|
2647
9b7e6d9a528d
typos, layout and other small things
Guido van Rossum <guido@python.org>
parents:
2576
diff
changeset
|
37 |
| 5818 | 38 \bcode\begin{verbatim} |
|
2647
9b7e6d9a528d
typos, layout and other small things
Guido van Rossum <guido@python.org>
parents:
2576
diff
changeset
|
39 urlparse('http://www.cwi.nl:80/%7Eguido/Python.html') |
| 5818 | 40 \end{verbatim}\ecode |
| 41 % | |
| 2449 | 42 yields the tuple |
|
2647
9b7e6d9a528d
typos, layout and other small things
Guido van Rossum <guido@python.org>
parents:
2576
diff
changeset
|
43 |
| 5818 | 44 \bcode\begin{verbatim} |
|
2647
9b7e6d9a528d
typos, layout and other small things
Guido van Rossum <guido@python.org>
parents:
2576
diff
changeset
|
45 ('http', 'www.cwi.nl:80', '/%7Eguido/Python.html', '', '', '') |
| 5818 | 46 \end{verbatim}\ecode |
| 47 % | |
| 2449 | 48 If the \var{default_scheme} argument is specified, it gives the |
| 49 default addressing scheme, to be used only if the URL string does not | |
| 50 specify one. The default value for this argument is the empty string. | |
| 51 | |
| 52 If the \var{allow_fragments} argument is zero, fragment identifiers | |
| 53 are not allowed, even if the URL's addressing scheme normally does | |
| 54 support them. The default value for this argument is \code{1}. | |
| 55 \end{funcdesc} | |
| 56 | |
| 57 \begin{funcdesc}{urlunparse}{tuple} | |
| 58 Construct a URL string from a tuple as returned by \code{urlparse}. | |
| 59 This may result in a slightly different, but equivalent URL, if the | |
| 60 URL that was parsed originally had redundant delimiters, e.g. a ? with | |
| 61 an empty query (the draft states that these are equivalent). | |
| 62 \end{funcdesc} | |
| 63 | |
| 64 \begin{funcdesc}{urljoin}{base\, url\optional{\, allow_fragments}} | |
| 65 Construct a full (``absolute'') URL by combining a ``base URL'' | |
| 66 (\var{base}) with a ``relative URL'' (\var{url}). Informally, this | |
| 67 uses components of the base URL, in particular the addressing scheme, | |
| 68 the network location and (part of) the path, to provide missing | |
| 69 components in the relative URL. | |
| 70 | |
| 71 Example: | |
|
2647
9b7e6d9a528d
typos, layout and other small things
Guido van Rossum <guido@python.org>
parents:
2576
diff
changeset
|
72 |
| 5818 | 73 \bcode\begin{verbatim} |
|
2647
9b7e6d9a528d
typos, layout and other small things
Guido van Rossum <guido@python.org>
parents:
2576
diff
changeset
|
74 urljoin('http://www.cwi.nl/%7Eguido/Python.html', 'FAQ.html') |
| 5818 | 75 \end{verbatim}\ecode |
| 76 % | |
|
2647
9b7e6d9a528d
typos, layout and other small things
Guido van Rossum <guido@python.org>
parents:
2576
diff
changeset
|
77 yields the string |
|
9b7e6d9a528d
typos, layout and other small things
Guido van Rossum <guido@python.org>
parents:
2576
diff
changeset
|
78 |
| 5818 | 79 \bcode\begin{verbatim} |
|
2647
9b7e6d9a528d
typos, layout and other small things
Guido van Rossum <guido@python.org>
parents:
2576
diff
changeset
|
80 'http://www.cwi.nl/%7Eguido/FAQ.html' |
| 5818 | 81 \end{verbatim}\ecode |
| 82 % | |
| 2449 | 83 The \var{allow_fragments} argument has the same meaning as for |
| 84 \code{urlparse}. | |
| 85 \end{funcdesc} |
