GNU Info

Info Node: (python2.1-lib.info)Urllib Examples

(python2.1-lib.info)Urllib Examples


Prev: URLopener Objects Up: urllib
Enter node , (file) or (file)node

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()


automatically generated by info2www version 1.2.2.9