def add_params_to_url ( url , params ) : url_parts = list ( urlparse . urlparse ( url ) ) # get url parts query = dict ( urlparse . parse_qsl ( url_parts [ 4 ] ) ) # get url query query . update ( params ) # add new params url_parts [ 4 ] = urlencode ( query ) return urlparse . urlunparse ( url_parts )
python add query params to url
Adds params to url
def add_params_to_url(url, params):
    """Adds params to url

    :param url: Url
    :param params: Params to add
    :return: original url with new params
    """
    url_parts = list(urlparse.urlparse(url))  # get url parts
    query = dict(urlparse.parse_qsl(url_parts[4]))  # get url query
    query.update(params)  # add new params
    url_parts[4] = urlencode(query)
    return urlparse.urlunparse(url_parts)