examples the following examples show how to turn dictionary of query variables into url suitable for use in an http get request and how you can parse urltryfrom urllib parse import urlparseurlencodeparse_qsl except importerrorfrom urlparse import urlparseparse_qsl from urllib import urlencode python python example of creating url with properly encoded query varibles form_fields 'name'dave''email'dave@dabeaz com''uid' form_data urlencode(form_fieldsurl "example of parsing url into components urlparse(urlprint( scheme'httpprint( netloc'www somehost comprint( path'/cgi-bin/view pyprint( params'print( query'uid= &name=dave&email=dave% dabeaz comprint( fragment'extract query data parsed_fields dict(parse_qsl( query)assert form_fields =parsed_fields urllib error the urllib error module defines exceptions used by the urllib package contenttooshort raised when the amount of downloaded data is less than the expected amount (as defined by the 'content-lengthheaderdefined in the urllib module in python httperror raised to indicate problems with the http protocol this error may be used to signal events such as authentication required this exception can also be used as file object to read the data returned by the server that' associated with the error this is subclass of urlerror it is defined in the urllib module in python urlerror error raised by handlers when problem is detected this is subclass of ioerror the reason attribute of the exception instance has more information about the problem this is defined in the urllib module in python urllib robotparser (robotparserthe urllib robotparser module (robotparser in python is used to fetch and parse the contents of 'robots txtfiles used to instruct web crawlers consult the online documentation for further usage information lib fl ff