def clean_url ( url ) : parsed = urlparse ( url . strip ( ) ) reconstructed = ParseResult ( parsed . scheme , parsed . netloc , parsed . path , params = '' , query = '' , fragment = '' ) return reconstructed . geturl ( )
python clean url function
Remove params query and fragment parts from URL so that os . path . basename and os . path . splitext can work correctly .
def clean_url(url):
    """
    Remove params, query and fragment parts from URL so that `os.path.basename`
    and `os.path.splitext` can work correctly.

    @param url: URL to clean.
    @type url: str

    @return: Cleaned URL.
    @rtype: str
    """
    parsed = urlparse(url.strip())
    reconstructed = ParseResult(
        parsed.scheme, parsed.netloc, parsed.path,
        params='', query='', fragment='')
    return reconstructed.geturl()