[ Web Proxy ]
URL:
Viewing: https://docs.python.org/2.2/lib/node309.html [Back]  [Original]

11.4.2 Examples

11.4.2 Examples

Here is an example session that uses the "GET" method to retrieve a URL containing parameters:

>>> import urllib
>>> params = urllib.urlencode({'spam': 1, 'eggs': 2, 'bacon': 0})
>>> f = urllib.urlopen("http://www.musi-cal.com/cgi-bin/query?%s" % params)
>>> print f.read()

The following example uses the "POST" method instead:

>>> import urllib
>>> params = urllib.urlencode({'spam': 1, 'eggs': 2, 'bacon': 0})
>>> f = urllib.urlopen("http://www.musi-cal.com/cgi-bin/query", params)
>>> print f.read()
See About this document... for information on suggesting changes.
Web Proxy Viewer  |  New URL  |  Original Page