I use requests to solve twitter urls, it works for all valid URLs, but if the URL cant be resolved, the variable r will get me the the input value as response. If I copy the URL into a browser I it wont get loaded, but the url will be resolved.
Is there a method, to resolve redirection URLs, also when the target-url can't get loaded.
def unshortenTwitterURL(url):
try:
r = requests.head(url, allow_redirects=True, timeout=10)
res = r.url
except:
res = url
return res