How can I un-shorten a URL using python?

后端 未结 4 1582
孤城傲影
孤城傲影 2020-12-08 12:22

I have seen this thread already - How can I unshorten a URL?

My issue with the resolved answer (that is using the unshort.me API) is that I am focusing on unshorteni

4条回答
  •  难免孤独
    2020-12-08 13:01

    one line functions, using requests library and yes, it supports recursion.

    def unshorten_url(url):
        return requests.head(url, allow_redirects=True).url
    

提交回复
热议问题