ops
This commit is contained in:
@@ -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'] = ''
|
||||
|
||||
Reference in New Issue
Block a user