This commit is contained in:
marco
2020-12-08 21:08:51 +01:00
parent 0d8af39a0c
commit 601962df83
2 changed files with 18 additions and 14 deletions

View File

@@ -389,8 +389,16 @@ def downloadpage(url, **opt):
response_code = req.status_code
response['url'] = req.url
response['data'] = req.content if req.content else ''
if type(response['data']) != str:
try:
response['data'] = response['data'].decode('utf-8')
except:
response['data'] = response['data'].decode('ISO-8859-1')
if req.headers.get('Server', '').startswith('cloudflare') and response_code in [429, 503, 403]\
and not opt.get('CF', False) and 'Please turn JavaScript on and reload the page' in req.content:
and not opt.get('CF', False) and 'Please turn JavaScript on and reload the page' in response['data']:
logger.debug("CF retry... for domain: %s" % domain)
from lib import proxytranslate
gResp = proxytranslate.process_request_proxy(url)
@@ -399,14 +407,6 @@ def downloadpage(url, **opt):
response_code = req.status_code
response['url'] = gResp['url']
response['data'] = gResp['data']
else:
response['data'] = req.content if req.content else ''
if type(response['data']) != str:
try:
response['data'] = response['data'].decode('utf-8')
except:
response['data'] = response['data'].decode('ISO-8859-1')
if not response['data']:
response['data'] = ''