Fix alternativo a redirect

This commit is contained in:
marco
2022-05-04 21:11:41 +02:00
parent 277701c90c
commit 17f103aebd
4 changed files with 19 additions and 15 deletions
+7 -1
View File
@@ -375,8 +375,14 @@ def downloadpage(url, **opt):
timeout=opt['timeout'])
else:
# Makes the request with POST method
req = session.post(url, data=payload, allow_redirects=opt.get('follow_redirects', True),
req = session.post(url, data=payload, allow_redirects=False,
files=files, timeout=opt['timeout'])
# Make sure it follows redirects
i = 10
while opt.get('follow_redirects', True) and i > 0 and req.status_code == 301:
req = session.post(req.headers['Location'], data=payload, allow_redirects=False,
files=files, timeout=opt['timeout'])
i -= 1
elif opt.get('only_headers', False):
info_dict = fill_fields_pre(url, opt, proxy_data, file_name)