here's an adaptation of the PHP script I linked in the comments:
import pycurl
import sys
import StringIO
o = StringIO.StringIO()
h = StringIO.StringIO()
c = pycurl.Curl()
c.setopt(c.URL, 'http://stackoverflow.com/questions/21444891')
# c.setopt(c.HTTPPOST, values)
c.setopt(c.WRITEFUNCTION, o.write)
c.setopt(c.HEADERFUNCTION, h.write)
c.setopt(c.CONNECTTIMEOUT, 30)
c.setopt(c.AUTOREFERER,1)
c.setopt(c.FOLLOWLOCATION, 1)
c.setopt(c.COOKIEFILE, '')
c.setopt(c.TIMEOUT, 30)
c.setopt(c.USERAGENT, '')
c.perform()
h.seek(0)
location = ""
for l in h:
if "Location" in l:
location = l.split(": ")[-1]
print location
though, as this example shows, you may not always have the full URI, only the path part of the URI (but if that's the case, that's easy to add the fqdn back)