How to get redirect url using Excel VBA or Python
Getting some tiny URL, that redirects you to somewhere else might be dangerous. There are a lot of people, that would never ever click on bit.ly/something or goo.gl/something, just because they do not know where the redirect is going to bring them. And they probably have a point.

Anyway, here I will show you how to get the target of the redirect url with Excel VBA and with Python.
With Python we use Requests
import requests
def main():
short_url = "https://bit.ly/3fW7cdQ"
r = requests.get(short_url)
print(r.url)
print(r.headers)
if __name__ == "__main__":
main()
With Excel VBA we use CreateObject(“WinHTTP.WinHTTPRequest.5.1”)
Sub Main()
Debug.Print Shortener("https://bit.ly/3tWiGGs")
End Sub
Public Function Shortener(tinyUrl As String) As String
Dim myRequest As Object
Set myRequest = CreateObject("WinHTTP.WinHTTPRequest.5.1")
With myRequest
.Open "HEAD", tinyUrl, False
.option(6) = True
.option(12) = True
.send
Shortener = .option(1)
End With
End Function
Well, that’s all!