Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(14)

Side by Side Diff: Doc/howto/urllib2.rst

Issue 10639: reindent.py converts newlines to platform default
Patch Set: Created 8 years, 8 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Doc/howto/logging-cookbook.rst ('k') | Doc/install/install.rst » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 .. _urllib-howto: 1 .. _urllib-howto:
2 2
3 *********************************************************** 3 ***********************************************************
4 HOWTO Fetch Internet Resources Using The urllib Package 4 HOWTO Fetch Internet Resources Using The urllib Package
5 *********************************************************** 5 ***********************************************************
6 6
7 :Author: `Michael Foord <http://www.voidspace.org.uk/python/index.shtml>`_ 7 :Author: `Michael Foord <http://www.voidspace.org.uk/python/index.shtml>`_
8 8
9 .. note:: 9 .. note::
10 10
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 >>> import urllib.parse 133 >>> import urllib.parse
134 >>> data = {} 134 >>> data = {}
135 >>> data['name'] = 'Somebody Here' 135 >>> data['name'] = 'Somebody Here'
136 >>> data['location'] = 'Northampton' 136 >>> data['location'] = 'Northampton'
137 >>> data['language'] = 'Python' 137 >>> data['language'] = 'Python'
138 >>> url_values = urllib.parse.urlencode(data) 138 >>> url_values = urllib.parse.urlencode(data)
139 >>> print(url_values) 139 >>> print(url_values)
140 name=Somebody+Here&language=Python&location=Northampton 140 name=Somebody+Here&language=Python&location=Northampton
141 >>> url = 'http://www.example.com/example.cgi' 141 >>> url = 'http://www.example.com/example.cgi'
142 >>> full_url = url + '?' + url_values 142 >>> full_url = url + '?' + url_values
143 >>> data = urllib.request.urlopen(full_url) 143 >>> data = urllib.request.open(full_url)
144 144
145 Notice that the full URL is created by adding a ``?`` to the URL, followed by 145 Notice that the full URL is created by adding a ``?`` to the URL, followed by
146 the encoded values. 146 the encoded values.
147 147
148 Headers 148 Headers
149 ------- 149 -------
150 150
151 We'll discuss here one particular HTTP header, to illustrate how to add headers 151 We'll discuss here one particular HTTP header, to illustrate how to add headers
152 to your HTTP request. 152 to your HTTP request.
153 153
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 .. [#] For details of more HTTP request headers, see 576 .. [#] For details of more HTTP request headers, see
577 `Quick Reference to HTTP Headers`_. 577 `Quick Reference to HTTP Headers`_.
578 .. [#] In my case I have to use a proxy to access the internet at work. If you 578 .. [#] In my case I have to use a proxy to access the internet at work. If you
579 attempt to fetch *localhost* URLs through this proxy it blocks them. IE 579 attempt to fetch *localhost* URLs through this proxy it blocks them. IE
580 is set to use the proxy, which urllib picks up on. In order to test 580 is set to use the proxy, which urllib picks up on. In order to test
581 scripts with a localhost server, I have to prevent urllib from using 581 scripts with a localhost server, I have to prevent urllib from using
582 the proxy. 582 the proxy.
583 .. [#] urllib opener for SSL proxy (CONNECT method): `ASPN Cookbook Recipe 583 .. [#] urllib opener for SSL proxy (CONNECT method): `ASPN Cookbook Recipe
584 <http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/456195>`_. 584 <http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/456195>`_.
585 585
OLDNEW
« no previous file with comments | « Doc/howto/logging-cookbook.rst ('k') | Doc/install/install.rst » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+