How can I unshorten a URL?

后端 未结 9 1060
时光说笑
时光说笑 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:33

    Open the url and see what it resolves to:

    >>> import urllib2
    >>> a = urllib2.urlopen('http://bit.ly/cXEInp')
    >>> print a.url
    http://www.flickr.com/photos/26432908@N00/346615997/sizes/l/
    >>> a = urllib2.urlopen('http://google.com')
    >>> print a.url
    http://www.google.com/
    

提交回复
热议问题