Well, I implemented a workaround. I’m no Python expert so this was cobbled together from what I found online, but it works.
<br />
#import urllib2<br />
<br />
class GetRedirectLocation(urllib2.HTTPRedirectHandler):<br />
def http_error_301(self, req, fp, code, msg, headers):<br />
return headers.get("Location")<br />
<br />
def GetRedirectIfPresent(url):<br />
req = urllib2.Request(url)<br />
opener = urllib2.build_opener(GetRedirectLocation())<br />
redirect = opener.open(req)<br />
<br />
if isinstance(redirect, str): # If not a 301 it won't hit the custom function above and will return a normal response object<br />
return redirect<br />
<br />
return url<br />