#NEWLINE# def url_query_parameter( url , parameter , default = None , keep_blank_values = 0 ) : #NEWLINE# #INDENT# 'Return the value of a url parameter, given the url and parameter name\n\n    General case:\n\n    >>> import w3lib.url\n    >>> w3lib.url.url_query_parameter("product.html?id=200&foo=bar", "id")\n    \'200\'\n    >>>\n\n    Return a default value if the parameter is not found:\n\n    >>> w3lib.url.url_query_parameter("product.html?id=200&foo=bar", "notthere", "mydefault")\n    \'mydefault\'\n    >>>\n\n    Returns None if `keep_blank_values` not set or 0 (default):\n\n    >>> w3lib.url.url_query_parameter("product.html?id=", "id")\n    >>>\n\n    Returns an empty string if `keep_blank_values` set to 1:\n\n    >>> w3lib.url.url_query_parameter("product.html?id=", "id", keep_blank_values=1)\n    \'\'\n    >>>\n\n    ' #NEWLINE# queryparams = parse_qs ( urlsplit ( str ( url ) ) [ 3 ] , keep_blank_values = keep_blank_values ) #NEWLINE# return queryparams . get ( parameter , [ default ] ) [ 0 ]