import requests


def getJumpFinalUrl(url: str, maxJump: int = 5) -> str:
    """
    获取一个URL最终重定向的URL
    :param url: 原来的URL
    :param maxJump: 最大重定向次数,最大为5
    :return: 最终重定向的URL
    """
    jump = 0
    maxJump = min(maxJump, 5)  # 最大重定向的值为5
    while jump < maxJump:
        response = requests.head(url)
        if response.status_code == 302:
            url = response.headers['Location']
            jump += 1
        else:
            return url
    raise Exception("超出最大重定向次数!")