import requests


def get_redirect_url(url):
    res = requests.get(url, allow_redirects=False)
    if res.status_code == 302 or res.status_code == 301:
        new_url = res.headers['Location']
        return new_url
    else:
        return url
