annotate Doc/liburlparse.tex @ 5817:48b94de85bf3 legacy-trunk

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