def remove_args(url, keep_params=(), frags=False):
 parsed = urlsplit(url)
 filtered_query = '&'.join((qry_item for qry_item in parsed.query.split('&') if qry_item.startswith(keep_params)))
 if frags:
  frag = parsed[4:]
 else:
  frag = ('',)
 return urlunsplit(((parsed[:3] + (filtered_query,)) + frag))

def remove_args ( url , keep_params = ( ) , frags = False ) : parsed = urlsplit ( url ) filtered_query = '&' . join ( ( qry_item for qry_item in parsed . query . split ( '&' ) if qry_item . startswith ( keep_params ) ) ) if frags : frag = parsed [ 4 : ] else : frag = ( '' , ) return urlunsplit ( ( ( parsed [ : 3 ] + ( filtered_query , ) ) + frag ) )
remove all param arguments from a url .