Unwrapping t.co link that links to bit.ly
Question: I'm trying to get the URL that has been already shortened by bit.ly and again
by twitter. I have already tried:

    
    
    import urllib.request
    r = urllib.request.urlopen(url)
    r.url
    

Also by using libraries such as [requests](http://docs.python-
requests.org/en/latest/) and [httplib2](http://code.google.com/p/httplib2/).

All these solutions would work if i wanted the final destination for the t.co
link, however, I do need the intermediate shortener, which I now I can get via
a HEAD request but I can't get Python 3 http.client working in order to get
the location. Any ideas?


Answer: 
    >>> c = http.client.HTTPConnection('t.co')
    >>> c.request('GET', '/7fGoazTYpc')          # or HEAD, but body is empty anyway
    >>> r = c.getresponse()
    >>> r.getheader('Location')
    'http://bit.ly/900913'
    

