mirror of
https://github.com/cquest/tootbot.git
synced 2024-11-23 20:11:06 +00:00
handle https broken redirectors like ow.ly or u.afp.com
This commit is contained in:
parent
1b68e9e6b4
commit
92c3992708
|
@ -24,7 +24,11 @@ def unredir(redir):
|
||||||
redir = redir.replace('https://ow.ly/', 'http://ow.ly/') # only http
|
redir = redir.replace('https://ow.ly/', 'http://ow.ly/') # only http
|
||||||
redir = requests.get(redir, allow_redirects=False).headers.get('Location')
|
redir = requests.get(redir, allow_redirects=False).headers.get('Location')
|
||||||
print('redir+', redir)
|
print('redir+', redir)
|
||||||
r = requests.get(redir, allow_redirects=False)
|
try:
|
||||||
|
r = requests.get(redir, allow_redirects=False, timeout=5)
|
||||||
|
except:
|
||||||
|
redir = redir.replace('https://', 'http://') # only http ?
|
||||||
|
r = requests.get(redir, allow_redirects=False)
|
||||||
return redir
|
return redir
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user