home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 5 / DATAFILE_PDCD5.iso / utilities / p / python / pytexdoc / ext / lib / lib1 / urllib / tex
LaTeX Document  |  1996-11-08  |  4.6 KB

open in: MacOS 8.1     |     Win98     |     DOS

view JSON data     |     view as text

This file was processed as: LaTeX Document (document/latex).

You can browse this item here: tex

ConfidenceProgramDetectionMatch TypeSupport
100% dexvert LaTeX Document (document/latex) magic Supported
1% dexvert Text File (text/txt) fallback Supported
100% file LaTeX document text default
99% file LaTeX document, ASCII text default
100% checkBytes Printable ASCII default
100% perlTextCheck Likely Text (Perl) default
100% siegfried fmt/281 LaTeX (Subdocument) default
100% detectItEasy Format: plain text[LF] default (weak)



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 5c 73 65 63 74 69 6f 6e | 7b 53 74 61 6e 64 61 72 |\section|{Standar|
|00000010| 64 20 4d 6f 64 75 6c 65 | 20 5c 73 65 63 74 63 6f |d Module| \sectco|
|00000020| 64 65 7b 75 72 6c 6c 69 | 62 7d 7d 0a 5c 73 74 6d |de{urlli|b}}.\stm|
|00000030| 6f 64 69 6e 64 65 78 7b | 75 72 6c 6c 69 62 7d 0a |odindex{|urllib}.|
|00000040| 5c 69 6e 64 65 78 7b 57 | 57 57 7d 0a 5c 69 6e 64 |\index{W|WW}.\ind|
|00000050| 65 78 7b 57 6f 72 6c 64 | 2d 57 69 64 65 20 57 65 |ex{World|-Wide We|
|00000060| 62 7d 0a 5c 69 6e 64 65 | 78 7b 55 52 4c 7d 0a 0a |b}.\inde|x{URL}..|
|00000070| 5c 72 65 6e 65 77 63 6f | 6d 6d 61 6e 64 7b 5c 69 |\renewco|mmand{\i|
|00000080| 6e 64 65 78 73 75 62 69 | 74 65 6d 7d 7b 28 69 6e |ndexsubi|tem}{(in|
|00000090| 20 6d 6f 64 75 6c 65 20 | 75 72 6c 6c 69 62 29 7d | module |urllib)}|
|000000a0| 0a 0a 54 68 69 73 20 6d | 6f 64 75 6c 65 20 70 72 |..This m|odule pr|
|000000b0| 6f 76 69 64 65 73 20 61 | 20 68 69 67 68 2d 6c 65 |ovides a| high-le|
|000000c0| 76 65 6c 20 69 6e 74 65 | 72 66 61 63 65 20 66 6f |vel inte|rface fo|
|000000d0| 72 20 66 65 74 63 68 69 | 6e 67 20 64 61 74 61 20 |r fetchi|ng data |
|000000e0| 61 63 72 6f 73 73 0a 74 | 68 65 20 57 6f 72 6c 64 |across.t|he World|
|000000f0| 2d 57 69 64 65 20 57 65 | 62 2e 20 20 49 6e 20 70 |-Wide We|b. In p|
|00000100| 61 72 74 69 63 75 6c 61 | 72 2c 20 74 68 65 20 5c |articula|r, the \|
|00000110| 63 6f 64 65 7b 75 72 6c | 6f 70 65 6e 7d 20 66 75 |code{url|open} fu|
|00000120| 6e 63 74 69 6f 6e 20 69 | 73 0a 73 69 6d 69 6c 61 |nction i|s.simila|
|00000130| 72 20 74 6f 20 74 68 65 | 20 62 75 69 6c 74 2d 69 |r to the| built-i|
|00000140| 6e 20 66 75 6e 63 74 69 | 6f 6e 20 5c 63 6f 64 65 |n functi|on \code|
|00000150| 7b 6f 70 65 6e 7d 2c 20 | 62 75 74 20 61 63 63 65 |{open}, |but acce|
|00000160| 70 74 73 20 55 52 4c 73 | 0a 28 55 6e 69 76 65 72 |pts URLs|.(Univer|
|00000170| 73 61 6c 20 52 65 73 6f | 75 72 63 65 20 4c 6f 63 |sal Reso|urce Loc|
|00000180| 61 74 6f 72 73 29 20 69 | 6e 73 74 65 61 64 20 6f |ators) i|nstead o|
|00000190| 66 20 66 69 6c 65 6e 61 | 6d 65 73 2e 20 20 53 6f |f filena|mes. So|
|000001a0| 6d 65 20 72 65 73 74 72 | 69 63 74 69 6f 6e 73 0a |me restr|ictions.|
|000001b0| 61 70 70 6c 79 20 2d 2d | 2d 20 69 74 20 63 61 6e |apply --|- it can|
|000001c0| 20 6f 6e 6c 79 20 6f 70 | 65 6e 20 55 52 4c 73 20 | only op|en URLs |
|000001d0| 66 6f 72 20 72 65 61 64 | 69 6e 67 2c 20 61 6e 64 |for read|ing, and|
|000001e0| 20 6e 6f 20 73 65 65 6b | 20 6f 70 65 72 61 74 69 | no seek| operati|
|000001f0| 6f 6e 73 0a 61 72 65 20 | 61 76 61 69 6c 61 62 6c |ons.are |availabl|
|00000200| 65 2e 0a 0a 69 74 20 64 | 65 66 69 6e 65 73 20 74 |e...it d|efines t|
|00000210| 68 65 20 66 6f 6c 6c 6f | 77 69 6e 67 20 70 75 62 |he follo|wing pub|
|00000220| 6c 69 63 20 66 75 6e 63 | 74 69 6f 6e 73 3a 0a 0a |lic func|tions:..|
|00000230| 5c 62 65 67 69 6e 7b 66 | 75 6e 63 64 65 73 63 7d |\begin{f|uncdesc}|
|00000240| 7b 75 72 6c 6f 70 65 6e | 7d 7b 75 72 6c 7d 0a 4f |{urlopen|}{url}.O|
|00000250| 70 65 6e 20 61 20 6e 65 | 74 77 6f 72 6b 20 6f 62 |pen a ne|twork ob|
|00000260| 6a 65 63 74 20 64 65 6e | 6f 74 65 64 20 62 79 20 |ject den|oted by |
|00000270| 61 20 55 52 4c 20 66 6f | 72 20 72 65 61 64 69 6e |a URL fo|r readin|
|00000280| 67 2e 20 20 49 66 20 74 | 68 65 20 55 52 4c 20 64 |g. If t|he URL d|
|00000290| 6f 65 73 0a 6e 6f 74 20 | 68 61 76 65 20 61 20 73 |oes.not |have a s|
|000002a0| 63 68 65 6d 65 20 69 64 | 65 6e 74 69 66 69 65 72 |cheme id|entifier|
|000002b0| 2c 20 6f 72 20 69 66 20 | 69 74 20 68 61 73 20 5c |, or if |it has \|
|000002c0| 73 61 6d 70 7b 66 69 6c | 65 3a 7d 20 61 73 20 69 |samp{fil|e:} as i|
|000002d0| 74 73 20 73 63 68 65 6d | 65 0a 69 64 65 6e 74 69 |ts schem|e.identi|
|000002e0| 66 69 65 72 2c 20 74 68 | 69 73 20 6f 70 65 6e 73 |fier, th|is opens|
|000002f0| 20 61 20 6c 6f 63 61 6c | 20 66 69 6c 65 3b 20 6f | a local| file; o|
|00000300| 74 68 65 72 77 69 73 65 | 20 69 74 20 6f 70 65 6e |therwise| it open|
|00000310| 73 20 61 20 73 6f 63 6b | 65 74 20 74 6f 20 61 0a |s a sock|et to a.|
|00000320| 73 65 72 76 65 72 20 73 | 6f 6d 65 77 68 65 72 65 |server s|omewhere|
|00000330| 20 6f 6e 20 74 68 65 20 | 6e 65 74 77 6f 72 6b 2e | on the |network.|
|00000340| 20 20 49 66 20 74 68 65 | 20 63 6f 6e 6e 65 63 74 | If the| connect|
|00000350| 69 6f 6e 20 63 61 6e 6e | 6f 74 20 62 65 20 6d 61 |ion cann|ot be ma|
|00000360| 64 65 2c 20 6f 72 0a 69 | 66 20 74 68 65 20 73 65 |de, or.i|f the se|
|00000370| 72 76 65 72 20 72 65 74 | 75 72 6e 73 20 61 6e 20 |rver ret|urns an |
|00000380| 65 72 72 6f 72 20 63 6f | 64 65 2c 20 74 68 65 20 |error co|de, the |
|00000390| 5c 63 6f 64 65 7b 49 4f | 45 72 72 6f 72 7d 20 65 |\code{IO|Error} e|
|000003a0| 78 63 65 70 74 69 6f 6e | 20 69 73 0a 72 61 69 73 |xception| is.rais|
|000003b0| 65 64 2e 20 20 49 66 20 | 61 6c 6c 20 77 65 6e 74 |ed. If |all went|
|000003c0| 20 77 65 6c 6c 2c 20 61 | 20 66 69 6c 65 2d 6c 69 | well, a| file-li|
|000003d0| 6b 65 20 6f 62 6a 65 63 | 74 20 69 73 20 72 65 74 |ke objec|t is ret|
|000003e0| 75 72 6e 65 64 2e 20 20 | 54 68 69 73 0a 73 75 70 |urned. |This.sup|
|000003f0| 70 6f 72 74 73 20 74 68 | 65 20 66 6f 6c 6c 6f 77 |ports th|e follow|
|00000400| 69 6e 67 20 6d 65 74 68 | 6f 64 73 3a 20 5c 63 6f |ing meth|ods: \co|
|00000410| 64 65 7b 72 65 61 64 28 | 29 7d 2c 20 5c 63 6f 64 |de{read(|)}, \cod|
|00000420| 65 7b 72 65 61 64 6c 69 | 6e 65 28 29 7d 2c 0a 5c |e{readli|ne()},.\|
|00000430| 63 6f 64 65 7b 72 65 61 | 64 6c 69 6e 65 73 28 29 |code{rea|dlines()|
|00000440| 7d 2c 20 5c 63 6f 64 65 | 7b 66 69 6c 65 6e 6f 28 |}, \code|{fileno(|
|00000450| 29 7d 2c 20 5c 63 6f 64 | 65 7b 63 6c 6f 73 65 28 |)}, \cod|e{close(|
|00000460| 29 7d 20 61 6e 64 20 5c | 63 6f 64 65 7b 69 6e 66 |)} and \|code{inf|
|00000470| 6f 28 29 7d 2e 0a 45 78 | 63 65 70 74 20 66 6f 72 |o()}..Ex|cept for|
|00000480| 20 74 68 65 20 6c 61 73 | 74 20 6f 6e 65 2c 20 74 | the las|t one, t|
|00000490| 68 65 73 65 20 6d 65 74 | 68 6f 64 73 20 68 61 76 |hese met|hods hav|
|000004a0| 65 20 74 68 65 20 73 61 | 6d 65 20 69 6e 74 65 72 |e the sa|me inter|
|000004b0| 66 61 63 65 20 61 73 20 | 66 6f 72 0a 66 69 6c 65 |face as |for.file|
|000004c0| 20 6f 62 6a 65 63 74 73 | 20 2d 2d 2d 20 73 65 65 | objects| --- see|
|000004d0| 20 74 68 65 20 73 65 63 | 74 69 6f 6e 20 6f 6e 20 | the sec|tion on |
|000004e0| 46 69 6c 65 20 4f 62 6a | 65 63 74 73 20 65 61 72 |File Obj|ects ear|
|000004f0| 6c 69 65 72 20 69 6e 20 | 74 68 69 73 0a 6d 61 6e |lier in |this.man|
|00000500| 75 61 6c 2e 20 20 28 49 | 74 27 73 20 6e 6f 74 20 |ual. (I|t's not |
|00000510| 61 20 62 75 69 6c 74 2d | 69 6e 20 66 69 6c 65 20 |a built-|in file |
|00000520| 6f 62 6a 65 63 74 2c 20 | 68 6f 77 65 76 65 72 2c |object, |however,|
|00000530| 20 73 6f 20 69 74 20 63 | 61 6e 27 74 20 62 65 0a | so it c|an't be.|
|00000540| 75 73 65 64 20 61 74 20 | 74 68 6f 73 65 20 66 65 |used at |those fe|
|00000550| 77 20 70 6c 61 63 65 73 | 20 77 68 65 72 65 20 61 |w places| where a|
|00000560| 20 74 72 75 65 20 62 75 | 69 6c 74 2d 69 6e 20 66 | true bu|ilt-in f|
|00000570| 69 6c 65 20 6f 62 6a 65 | 63 74 20 69 73 0a 72 65 |ile obje|ct is.re|
|00000580| 71 75 69 72 65 64 2e 29 | 0a 0a 54 68 65 20 5c 63 |quired.)|..The \c|
|00000590| 6f 64 65 7b 69 6e 66 6f | 28 29 7d 20 6d 65 74 68 |ode{info|()} meth|
|000005a0| 6f 64 20 72 65 74 75 72 | 6e 73 20 61 6e 20 69 6e |od retur|ns an in|
|000005b0| 73 74 61 6e 63 65 20 6f | 66 20 74 68 65 20 63 6c |stance o|f the cl|
|000005c0| 61 73 73 0a 5c 63 6f 64 | 65 7b 72 66 63 38 32 32 |ass.\cod|e{rfc822|
|000005d0| 2e 4d 65 73 73 61 67 65 | 7d 20 63 6f 6e 74 61 69 |.Message|} contai|
|000005e0| 6e 69 6e 67 20 74 68 65 | 20 68 65 61 64 65 72 73 |ning the| headers|
|000005f0| 20 72 65 63 65 69 76 65 | 64 20 66 72 6f 6d 20 74 | receive|d from t|
|00000600| 68 65 20 73 65 72 76 65 | 72 2c 0a 69 66 20 74 68 |he serve|r,.if th|
|00000610| 65 20 70 72 6f 74 6f 63 | 6f 6c 20 75 73 65 73 20 |e protoc|ol uses |
|00000620| 73 75 63 68 20 68 65 61 | 64 65 72 73 20 28 63 75 |such hea|ders (cu|
|00000630| 72 72 65 6e 74 6c 79 20 | 74 68 65 20 6f 6e 6c 79 |rrently |the only|
|00000640| 20 73 75 70 70 6f 72 74 | 65 64 0a 70 72 6f 74 6f | support|ed.proto|
|00000650| 63 6f 6c 20 74 68 61 74 | 20 75 73 65 73 20 74 68 |col that| uses th|
|00000660| 69 73 20 69 73 20 48 54 | 54 50 29 2e 20 20 53 65 |is is HT|TP). Se|
|00000670| 65 20 74 68 65 20 64 65 | 73 63 72 69 70 74 69 6f |e the de|scriptio|
|00000680| 6e 20 6f 66 20 74 68 65 | 0a 5c 63 6f 64 65 7b 72 |n of the|.\code{r|
|00000690| 66 63 38 32 32 7d 20 6d | 6f 64 75 6c 65 2e 0a 5c |fc822} m|odule..\|
|000006a0| 65 6e 64 7b 66 75 6e 63 | 64 65 73 63 7d 0a 0a 5c |end{func|desc}..\|
|000006b0| 62 65 67 69 6e 7b 66 75 | 6e 63 64 65 73 63 7d 7b |begin{fu|ncdesc}{|
|000006c0| 75 72 6c 72 65 74 72 69 | 65 76 65 7d 7b 75 72 6c |urlretri|eve}{url|
|000006d0| 7d 0a 43 6f 70 79 20 61 | 20 6e 65 74 77 6f 72 6b |}.Copy a| network|
|000006e0| 20 6f 62 6a 65 63 74 20 | 64 65 6e 6f 74 65 64 20 | object |denoted |
|000006f0| 62 79 20 61 20 55 52 4c | 20 74 6f 20 61 20 6c 6f |by a URL| to a lo|
|00000700| 63 61 6c 20 66 69 6c 65 | 2c 20 69 66 20 6e 65 63 |cal file|, if nec|
|00000710| 65 73 73 61 72 79 2e 0a | 49 66 20 74 68 65 20 55 |essary..|If the U|
|00000720| 52 4c 20 70 6f 69 6e 74 | 73 20 74 6f 20 61 20 6c |RL point|s to a l|
|00000730| 6f 63 61 6c 20 66 69 6c | 65 2c 20 6f 72 20 61 20 |ocal fil|e, or a |
|00000740| 76 61 6c 69 64 20 63 61 | 63 68 65 64 20 63 6f 70 |valid ca|ched cop|
|00000750| 79 20 6f 66 20 74 68 65 | 0a 6f 62 6a 65 63 74 20 |y of the|.object |
|00000760| 65 78 69 73 74 73 2c 20 | 74 68 65 20 6f 62 6a 65 |exists, |the obje|
|00000770| 63 74 20 69 73 20 6e 6f | 74 20 63 6f 70 69 65 64 |ct is no|t copied|
|00000780| 2e 20 20 52 65 74 75 72 | 6e 20 61 20 74 75 70 6c |. Retur|n a tupl|
|00000790| 65 20 28 5c 76 61 72 7b | 66 69 6c 65 6e 61 6d 65 |e (\var{|filename|
|000007a0| 7d 2c 0a 5c 76 61 72 7b | 68 65 61 64 65 72 73 7d |},.\var{|headers}|
|000007b0| 29 20 77 68 65 72 65 20 | 5c 76 61 72 7b 66 69 6c |) where |\var{fil|
|000007c0| 65 6e 61 6d 65 7d 20 69 | 73 20 74 68 65 20 6c 6f |ename} i|s the lo|
|000007d0| 63 61 6c 20 66 69 6c 65 | 20 6e 61 6d 65 20 75 6e |cal file| name un|
|000007e0| 64 65 72 20 77 68 69 63 | 68 0a 74 68 65 20 6f 62 |der whic|h.the ob|
|000007f0| 6a 65 63 74 20 63 61 6e | 20 62 65 20 66 6f 75 6e |ject can| be foun|
|00000800| 64 2c 20 61 6e 64 20 5c | 76 61 72 7b 68 65 61 64 |d, and \|var{head|
|00000810| 65 72 73 7d 20 69 73 20 | 65 69 74 68 65 72 20 5c |ers} is |either \|
|00000820| 63 6f 64 65 7b 4e 6f 6e | 65 7d 20 28 66 6f 72 0a |code{Non|e} (for.|
|00000830| 61 20 6c 6f 63 61 6c 20 | 6f 62 6a 65 63 74 29 20 |a local |object) |
|00000840| 6f 72 20 77 68 61 74 65 | 76 65 72 20 74 68 65 20 |or whate|ver the |
|00000850| 5c 63 6f 64 65 7b 69 6e | 66 6f 28 29 7d 20 6d 65 |\code{in|fo()} me|
|00000860| 74 68 6f 64 20 6f 66 20 | 74 68 65 20 6f 62 6a 65 |thod of |the obje|
|00000870| 63 74 0a 72 65 74 75 72 | 6e 65 64 20 62 79 20 5c |ct.retur|ned by \|
|00000880| 63 6f 64 65 7b 75 72 6c | 6f 70 65 6e 28 29 7d 20 |code{url|open()} |
|00000890| 72 65 74 75 72 6e 65 64 | 20 28 66 6f 72 20 61 20 |returned| (for a |
|000008a0| 72 65 6d 6f 74 65 20 6f | 62 6a 65 63 74 2c 20 70 |remote o|bject, p|
|000008b0| 6f 73 73 69 62 6c 79 0a | 63 61 63 68 65 64 29 2e |ossibly.|cached).|
|000008c0| 20 20 45 78 63 65 70 74 | 69 6f 6e 73 20 61 72 65 | Except|ions are|
|000008d0| 20 74 68 65 20 73 61 6d | 65 20 61 73 20 66 6f 72 | the sam|e as for|
|000008e0| 20 5c 63 6f 64 65 7b 75 | 72 6c 6f 70 65 6e 28 29 | \code{u|rlopen()|
|000008f0| 7d 2e 0a 5c 65 6e 64 7b | 66 75 6e 63 64 65 73 63 |}..\end{|funcdesc|
|00000900| 7d 0a 0a 5c 62 65 67 69 | 6e 7b 66 75 6e 63 64 65 |}..\begi|n{funcde|
|00000910| 73 63 7d 7b 75 72 6c 63 | 6c 65 61 6e 75 70 7d 7b |sc}{urlc|leanup}{|
|00000920| 7d 0a 43 6c 65 61 72 20 | 74 68 65 20 63 61 63 68 |}.Clear |the cach|
|00000930| 65 20 74 68 61 74 20 6d | 61 79 20 68 61 76 65 20 |e that m|ay have |
|00000940| 62 65 65 6e 20 62 75 69 | 6c 74 20 75 70 20 62 79 |been bui|lt up by|
|00000950| 20 70 72 65 76 69 6f 75 | 73 20 63 61 6c 6c 73 20 | previou|s calls |
|00000960| 74 6f 0a 5c 63 6f 64 65 | 7b 75 72 6c 72 65 74 72 |to.\code|{urlretr|
|00000970| 69 65 76 65 28 29 7d 2e | 0a 5c 65 6e 64 7b 66 75 |ieve()}.|.\end{fu|
|00000980| 6e 63 64 65 73 63 7d 0a | 0a 5c 62 65 67 69 6e 7b |ncdesc}.|.\begin{|
|00000990| 66 75 6e 63 64 65 73 63 | 7d 7b 71 75 6f 74 65 7d |funcdesc|}{quote}|
|000009a0| 7b 73 74 72 69 6e 67 5c | 6f 70 74 69 6f 6e 61 6c |{string\|optional|
|000009b0| 7b 5c 2c 20 61 64 64 73 | 61 66 65 7d 7d 0a 52 65 |{\, adds|afe}}.Re|
|000009c0| 70 6c 61 63 65 20 73 70 | 65 63 69 61 6c 20 63 68 |place sp|ecial ch|
|000009d0| 61 72 61 63 74 65 72 73 | 20 69 6e 20 5c 76 61 72 |aracters| in \var|
|000009e0| 7b 73 74 72 69 6e 67 7d | 20 75 73 69 6e 67 20 74 |{string}| using t|
|000009f0| 68 65 20 5c 63 6f 64 65 | 7b 5c 25 78 78 7d 20 65 |he \code|{\%xx} e|
|00000a00| 73 63 61 70 65 2e 0a 4c | 65 74 74 65 72 73 2c 20 |scape..L|etters, |
|00000a10| 64 69 67 69 74 73 2c 20 | 61 6e 64 20 74 68 65 20 |digits, |and the |
|00000a20| 63 68 61 72 61 63 74 65 | 72 73 20 60 60 5c 63 6f |characte|rs ``\co|
|00000a30| 64 65 7b 5f 2c 2e 2d 7d | 27 27 20 61 72 65 20 6e |de{_,.-}|'' are n|
|00000a40| 65 76 65 72 20 71 75 6f | 74 65 64 2e 0a 54 68 65 |ever quo|ted..The|
|00000a50| 20 6f 70 74 69 6f 6e 61 | 6c 20 5c 76 61 72 7b 61 | optiona|l \var{a|
|00000a60| 64 64 73 61 66 65 7d 20 | 70 61 72 61 6d 65 74 65 |ddsafe} |paramete|
|00000a70| 72 20 73 70 65 63 69 66 | 69 65 73 20 61 64 64 69 |r specif|ies addi|
|00000a80| 74 69 6f 6e 61 6c 20 63 | 68 61 72 61 63 74 65 72 |tional c|haracter|
|00000a90| 73 0a 74 68 61 74 20 73 | 68 6f 75 6c 64 20 6e 6f |s.that s|hould no|
|00000aa0| 74 20 62 65 20 71 75 6f | 74 65 64 20 2d 2d 2d 20 |t be quo|ted --- |
|00000ab0| 69 74 73 20 64 65 66 61 | 75 6c 74 20 76 61 6c 75 |its defa|ult valu|
|00000ac0| 65 20 69 73 20 5c 63 6f | 64 65 7b 27 2f 27 7d 2e |e is \co|de{'/'}.|
|00000ad0| 0a 0a 45 78 61 6d 70 6c | 65 3a 20 5c 63 6f 64 65 |..Exampl|e: \code|
|00000ae0| 7b 71 75 6f 74 65 28 27 | 2f 5c 7e 63 6f 6e 6f 6c |{quote('|/\~conol|
|00000af0| 6c 79 2f 27 29 7d 20 79 | 69 65 6c 64 73 20 5c 63 |ly/')} y|ields \c|
|00000b00| 6f 64 65 7b 27 2f 5c 25 | 37 65 63 6f 6e 6e 6f 6c |ode{'/\%|7econnol|
|00000b10| 6c 79 2f 27 7d 2e 0a 5c | 65 6e 64 7b 66 75 6e 63 |ly/'}..\|end{func|
|00000b20| 64 65 73 63 7d 0a 0a 5c | 62 65 67 69 6e 7b 66 75 |desc}..\|begin{fu|
|00000b30| 6e 63 64 65 73 63 7d 7b | 75 6e 71 75 6f 74 65 7d |ncdesc}{|unquote}|
|00000b40| 7b 73 74 72 69 6e 67 7d | 0a 52 65 70 6c 61 63 65 |{string}|.Replace|
|00000b50| 20 5c 73 61 6d 70 7b 5c | 25 78 78 7d 20 65 73 63 | \samp{\|%xx} esc|
|00000b60| 61 70 65 73 20 62 79 20 | 74 68 65 69 72 20 73 69 |apes by |their si|
|00000b70| 6e 67 6c 65 2d 63 68 61 | 72 61 63 74 65 72 20 65 |ngle-cha|racter e|
|00000b80| 71 75 69 76 61 6c 65 6e | 74 2e 0a 0a 45 78 61 6d |quivalen|t...Exam|
|00000b90| 70 6c 65 3a 20 5c 63 6f | 64 65 7b 75 6e 71 75 6f |ple: \co|de{unquo|
|00000ba0| 74 65 28 27 2f 5c 25 37 | 45 63 6f 6e 6e 6f 6c 6c |te('/\%7|Econnoll|
|00000bb0| 79 2f 27 29 7d 20 79 69 | 65 6c 64 73 20 5c 63 6f |y/')} yi|elds \co|
|00000bc0| 64 65 7b 27 2f 5c 7e 63 | 6f 6e 6e 6f 6c 6c 79 2f |de{'/\~c|onnolly/|
|00000bd0| 27 7d 2e 0a 5c 65 6e 64 | 7b 66 75 6e 63 64 65 73 |'}..\end|{funcdes|
|00000be0| 63 7d 0a 0a 52 65 73 74 | 72 69 63 74 69 6f 6e 73 |c}..Rest|rictions|
|00000bf0| 3a 0a 0a 5c 62 65 67 69 | 6e 7b 69 74 65 6d 69 7a |:..\begi|n{itemiz|
|00000c00| 65 7d 0a 0a 5c 69 74 65 | 6d 0a 43 75 72 72 65 6e |e}..\ite|m.Curren|
|00000c10| 74 6c 79 2c 20 6f 6e 6c | 79 20 74 68 65 20 66 6f |tly, onl|y the fo|
|00000c20| 6c 6c 6f 77 69 6e 67 20 | 70 72 6f 74 6f 63 6f 6c |llowing |protocol|
|00000c30| 73 20 61 72 65 20 73 75 | 70 70 6f 72 74 65 64 3a |s are su|pported:|
|00000c40| 20 48 54 54 50 2c 20 28 | 76 65 72 73 69 6f 6e 73 | HTTP, (|versions|
|00000c50| 0a 30 2e 39 20 61 6e 64 | 20 31 2e 30 29 2c 20 47 |.0.9 and| 1.0), G|
|00000c60| 6f 70 68 65 72 20 28 62 | 75 74 20 6e 6f 74 20 47 |opher (b|ut not G|
|00000c70| 6f 70 68 65 72 2d 2b 29 | 2c 20 46 54 50 2c 20 61 |opher-+)|, FTP, a|
|00000c80| 6e 64 20 6c 6f 63 61 6c | 20 66 69 6c 65 73 2e 0a |nd local| files..|
|00000c90| 5c 69 6e 64 65 78 7b 48 | 54 54 50 7d 0a 5c 69 6e |\index{H|TTP}.\in|
|00000ca0| 64 65 78 7b 47 6f 70 68 | 65 72 7d 0a 5c 69 6e 64 |dex{Goph|er}.\ind|
|00000cb0| 65 78 7b 46 54 50 7d 0a | 0a 5c 69 74 65 6d 0a 54 |ex{FTP}.|.\item.T|
|00000cc0| 68 65 20 63 61 63 68 69 | 6e 67 20 66 65 61 74 75 |he cachi|ng featu|
|00000cd0| 72 65 20 6f 66 20 5c 63 | 6f 64 65 7b 75 72 6c 72 |re of \c|ode{urlr|
|00000ce0| 65 74 72 69 65 76 65 28 | 29 7d 20 68 61 73 20 62 |etrieve(|)} has b|
|00000cf0| 65 65 6e 20 64 69 73 61 | 62 6c 65 64 20 75 6e 74 |een disa|bled unt|
|00000d00| 69 6c 20 49 0a 66 69 6e | 64 20 74 68 65 20 74 69 |il I.fin|d the ti|
|00000d10| 6d 65 20 74 6f 20 68 61 | 63 6b 20 70 72 6f 70 65 |me to ha|ck prope|
|00000d20| 72 20 70 72 6f 63 65 73 | 73 69 6e 67 20 6f 66 20 |r proces|sing of |
|00000d30| 45 78 70 69 72 61 74 69 | 6f 6e 20 74 69 6d 65 20 |Expirati|on time |
|00000d40| 68 65 61 64 65 72 73 2e | 0a 0a 5c 69 74 65 6d 0a |headers.|..\item.|
|00000d50| 54 68 65 72 65 20 73 68 | 6f 75 6c 64 20 62 65 20 |There sh|ould be |
|00000d60| 61 20 66 75 6e 63 74 69 | 6f 6e 20 74 6f 20 71 75 |a functi|on to qu|
|00000d70| 65 72 79 20 77 68 65 74 | 68 65 72 20 61 20 70 61 |ery whet|her a pa|
|00000d80| 72 74 69 63 75 6c 61 72 | 20 55 52 4c 20 69 73 20 |rticular| URL is |
|00000d90| 69 6e 0a 74 68 65 20 63 | 61 63 68 65 2e 0a 0a 5c |in.the c|ache...\|
|00000da0| 69 74 65 6d 0a 46 6f 72 | 20 62 61 63 6b 77 61 72 |item.For| backwar|
|00000db0| 64 20 63 6f 6d 70 61 74 | 69 62 69 6c 69 74 79 2c |d compat|ibility,|
|00000dc0| 20 69 66 20 61 20 55 52 | 4c 20 61 70 70 65 61 72 | if a UR|L appear|
|00000dd0| 73 20 74 6f 20 70 6f 69 | 6e 74 20 74 6f 20 61 20 |s to poi|nt to a |
|00000de0| 6c 6f 63 61 6c 20 66 69 | 6c 65 0a 62 75 74 20 74 |local fi|le.but t|
|00000df0| 68 65 20 66 69 6c 65 20 | 63 61 6e 27 74 20 62 65 |he file |can't be|
|00000e00| 20 6f 70 65 6e 65 64 2c | 20 74 68 65 20 55 52 4c | opened,| the URL|
|00000e10| 20 69 73 20 72 65 2d 69 | 6e 74 65 72 70 72 65 74 | is re-i|nterpret|
|00000e20| 65 64 20 75 73 69 6e 67 | 20 74 68 65 20 46 54 50 |ed using| the FTP|
|00000e30| 0a 70 72 6f 74 6f 63 6f | 6c 2e 20 20 54 68 69 73 |.protoco|l. This|
|00000e40| 20 63 61 6e 20 73 6f 6d | 65 74 69 6d 65 73 20 63 | can som|etimes c|
|00000e50| 61 75 73 65 20 63 6f 6e | 66 75 73 69 6e 67 20 65 |ause con|fusing e|
|00000e60| 72 72 6f 72 20 6d 65 73 | 73 61 67 65 73 2e 0a 0a |rror mes|sages...|
|00000e70| 5c 69 74 65 6d 0a 54 68 | 65 20 5c 63 6f 64 65 7b |\item.Th|e \code{|
|00000e80| 75 72 6c 6f 70 65 6e 28 | 29 7d 20 61 6e 64 20 5c |urlopen(|)} and \|
|00000e90| 63 6f 64 65 7b 75 72 6c | 72 65 74 72 69 65 76 65 |code{url|retrieve|
|00000ea0| 28 29 7d 20 66 75 6e 63 | 74 69 6f 6e 73 20 63 61 |()} func|tions ca|
|00000eb0| 6e 20 63 61 75 73 65 0a | 61 72 62 69 74 72 61 72 |n cause.|arbitrar|
|00000ec0| 69 6c 79 20 6c 6f 6e 67 | 20 64 65 6c 61 79 73 20 |ily long| delays |
|00000ed0| 77 68 69 6c 65 20 77 61 | 69 74 69 6e 67 20 66 6f |while wa|iting fo|
|00000ee0| 72 20 61 20 6e 65 74 77 | 6f 72 6b 20 63 6f 6e 6e |r a netw|ork conn|
|00000ef0| 65 63 74 69 6f 6e 20 74 | 6f 20 62 65 0a 73 65 74 |ection t|o be.set|
|00000f00| 20 75 70 2e 20 20 54 68 | 69 73 20 6d 65 61 6e 73 | up. Th|is means|
|00000f10| 20 74 68 61 74 20 69 74 | 20 69 73 20 64 69 66 66 | that it| is diff|
|00000f20| 69 63 75 6c 74 20 74 6f | 20 62 75 69 6c 64 20 61 |icult to| build a|
|00000f30| 6e 20 69 6e 74 65 72 61 | 63 74 69 76 65 0a 77 65 |n intera|ctive.we|
|00000f40| 62 20 63 6c 69 65 6e 74 | 20 75 73 69 6e 67 20 74 |b client| using t|
|00000f50| 68 65 73 65 20 66 75 6e | 63 74 69 6f 6e 73 20 77 |hese fun|ctions w|
|00000f60| 69 74 68 6f 75 74 20 75 | 73 69 6e 67 20 74 68 72 |ithout u|sing thr|
|00000f70| 65 61 64 73 2e 0a 0a 5c | 69 74 65 6d 0a 54 68 65 |eads...\|item.The|
|00000f80| 20 64 61 74 61 20 72 65 | 74 75 72 6e 65 64 20 62 | data re|turned b|
|00000f90| 79 20 5c 63 6f 64 65 7b | 75 72 6c 6f 70 65 6e 28 |y \code{|urlopen(|
|00000fa0| 29 7d 20 6f 72 20 5c 63 | 6f 64 65 7b 75 72 6c 72 |)} or \c|ode{urlr|
|00000fb0| 65 74 72 69 65 76 65 28 | 29 7d 20 69 73 20 74 68 |etrieve(|)} is th|
|00000fc0| 65 0a 72 61 77 20 64 61 | 74 61 20 72 65 74 75 72 |e.raw da|ta retur|
|00000fd0| 6e 65 64 20 62 79 20 74 | 68 65 20 73 65 72 76 65 |ned by t|he serve|
|00000fe0| 72 2e 20 20 54 68 69 73 | 20 6d 61 79 20 62 65 20 |r. This| may be |
|00000ff0| 62 69 6e 61 72 79 20 64 | 61 74 61 20 28 65 2e 67 |binary d|ata (e.g|
|00001000| 2e 20 61 6e 0a 69 6d 61 | 67 65 29 2c 20 70 6c 61 |. an.ima|ge), pla|
|00001010| 69 6e 20 74 65 78 74 20 | 6f 72 20 28 66 6f 72 20 |in text |or (for |
|00001020| 65 78 61 6d 70 6c 65 29 | 20 48 54 4d 4c 2e 20 20 |example)| HTML. |
|00001030| 54 68 65 20 48 54 54 50 | 20 70 72 6f 74 6f 63 6f |The HTTP| protoco|
|00001040| 6c 20 70 72 6f 76 69 64 | 65 73 0a 74 79 70 65 20 |l provid|es.type |
|00001050| 69 6e 66 6f 72 6d 61 74 | 69 6f 6e 20 69 6e 20 74 |informat|ion in t|
|00001060| 68 65 20 72 65 70 6c 79 | 20 68 65 61 64 65 72 2c |he reply| header,|
|00001070| 20 77 68 69 63 68 20 63 | 61 6e 20 62 65 20 69 6e | which c|an be in|
|00001080| 73 70 65 63 74 65 64 20 | 62 79 0a 6c 6f 6f 6b 69 |spected |by.looki|
|00001090| 6e 67 20 61 74 20 74 68 | 65 20 5c 63 6f 64 65 7b |ng at th|e \code{|
|000010a0| 43 6f 6e 74 65 6e 74 2d | 74 79 70 65 7d 20 68 65 |Content-|type} he|
|000010b0| 61 64 65 72 2e 20 20 46 | 6f 72 20 74 68 65 20 47 |ader. F|or the G|
|000010c0| 6f 70 68 65 72 20 70 72 | 6f 74 6f 63 6f 6c 2c 0a |opher pr|otocol,.|
|000010d0| 74 79 70 65 20 69 6e 66 | 6f 72 6d 61 74 69 6f 6e |type inf|ormation|
|000010e0| 20 69 73 20 65 6e 63 6f | 64 65 64 20 69 6e 20 74 | is enco|ded in t|
|000010f0| 68 65 20 55 52 4c 3b 20 | 74 68 65 72 65 20 69 73 |he URL; |there is|
|00001100| 20 63 75 72 72 65 6e 74 | 6c 79 20 6e 6f 20 65 61 | current|ly no ea|
|00001110| 73 79 20 77 61 79 0a 74 | 6f 20 65 78 74 72 61 63 |sy way.t|o extrac|
|00001120| 74 20 69 74 2e 20 20 49 | 66 20 74 68 65 20 72 65 |t it. I|f the re|
|00001130| 74 75 72 6e 65 64 20 64 | 61 74 61 20 69 73 20 48 |turned d|ata is H|
|00001140| 54 4d 4c 2c 20 79 6f 75 | 20 63 61 6e 20 75 73 65 |TML, you| can use|
|00001150| 20 74 68 65 20 6d 6f 64 | 75 6c 65 0a 5c 63 6f 64 | the mod|ule.\cod|
|00001160| 65 7b 68 74 6d 6c 6c 69 | 62 7d 20 74 6f 20 70 61 |e{htmlli|b} to pa|
|00001170| 72 73 65 20 69 74 2e 0a | 5c 69 6e 64 65 78 7b 48 |rse it..|\index{H|
|00001180| 54 4d 4c 7d 0a 5c 69 6e | 64 65 78 7b 48 54 54 50 |TML}.\in|dex{HTTP|
|00001190| 7d 0a 5c 69 6e 64 65 78 | 7b 47 6f 70 68 65 72 7d |}.\index|{Gopher}|
|000011a0| 0a 5c 73 74 6d 6f 64 69 | 6e 64 65 78 7b 68 74 6d |.\stmodi|ndex{htm|
|000011b0| 6c 6c 69 62 7d 0a 0a 5c | 69 74 65 6d 0a 41 6c 74 |llib}..\|item.Alt|
|000011c0| 68 6f 75 67 68 20 74 68 | 65 20 5c 63 6f 64 65 7b |hough th|e \code{|
|000011d0| 75 72 6c 6c 69 62 7d 20 | 6d 6f 64 75 6c 65 20 63 |urllib} |module c|
|000011e0| 6f 6e 74 61 69 6e 73 20 | 28 75 6e 64 6f 63 75 6d |ontains |(undocum|
|000011f0| 65 6e 74 65 64 29 20 72 | 6f 75 74 69 6e 65 73 20 |ented) r|outines |
|00001200| 74 6f 0a 70 61 72 73 65 | 20 61 6e 64 20 75 6e 70 |to.parse| and unp|
|00001210| 61 72 73 65 20 55 52 4c | 20 73 74 72 69 6e 67 73 |arse URL| strings|
|00001220| 2c 20 74 68 65 20 72 65 | 63 6f 6d 6d 65 6e 64 65 |, the re|commende|
|00001230| 64 20 69 6e 74 65 72 66 | 61 63 65 20 66 6f 72 20 |d interf|ace for |
|00001240| 55 52 4c 0a 6d 61 6e 69 | 70 75 6c 61 74 69 6f 6e |URL.mani|pulation|
|00001250| 20 69 73 20 69 6e 20 6d | 6f 64 75 6c 65 20 5c 63 | is in m|odule \c|
|00001260| 6f 64 65 7b 75 72 6c 70 | 61 72 73 65 7d 2e 0a 5c |ode{urlp|arse}..\|
|00001270| 73 74 6d 6f 64 69 6e 64 | 65 78 7b 75 72 6c 70 61 |stmodind|ex{urlpa|
|00001280| 72 73 65 7d 0a 0a 5c 65 | 6e 64 7b 69 74 65 6d 69 |rse}..\e|nd{itemi|
|00001290| 7a 65 7d 0a | |ze}. | |
+--------+-------------------------+-------------------------+--------+--------+