def get_json(api, data):
if session.cookies.get('_m_h5_tk', '') == '':
setup_token()
url = get_request_url(api, data)
text = retry(3, session.get, url, timeout=30).text
if u'????' in text or u'????' in text:
setup_token()
return get_json(api, data)
elif u'?????' in text or u'ID??' in text or u'???????' in text or u'?????' in text:
return {'error': 'not found'}
elif u'??????' in text:
raise NotFoundError("Taobao Api Error")
else:
resp = json.loads(text.strip()[6:-1])
if not resp['ret'][0].startswith('SUCCESS'):
raise ValueError('Unknown API Failure: {}'.format(text.encode('utf-8')))
else:
return resp
评论列表
文章目录