h5.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:data007 作者: mobishift2011 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号