How can I unshorten a URL?

后端 未结 9 1040
时光说笑
时光说笑 2020-11-30 05:19

I want to be able to take a shortened or non-shortened URL and return its un-shortened form. How can I make a python program to do this?

Additional Clarification:

相关标签:
9条回答
  • 2020-11-30 05:40

    If you are using Python 3.5+ you can use the Unshortenit module that makes this very easy:

    from unshortenit import UnshortenIt
    unshortener = UnshortenIt()
    uri = unshortener.unshorten('https://href.li/?https://example.com')
    
    0 讨论(0)
  • 2020-11-30 05:41

    Unshorten.me has an api that lets you send a JSON or XML request and get the full URL returned.

    0 讨论(0)
  • 2020-11-30 05:43

    You can use geturl()

    from urllib.request import urlopen
    url = "bit.ly/silly"
    unshortened_url = urlopen(url).geturl()
    print(unshortened_url)
    # google.com
    
    0 讨论(0)
提交回复
热议问题