调用实体标注API出现异常
choleraa 发布于2018-01 浏览:6507 回复:7
0
收藏
# content包含错误信息, 导致不能直接被Json处理, 暂时手动赋值
content = '{"access_token":"24.f09dc12acdee91c09ae29b28568d0e4f.2592000.1517625677.282335-10438002","session_key":"sample\\/iVP\\/sample+89hJ9YmmxQBtuGcsGmHf0cIU75yzHWUzheeVR3irQ==","scope":"brain_kg_cognitive iknow-antispam_spamauth public nlp_simnet nlp_wordemb nlp_comtag brain_all_scope brain_nlp_comment_tag brain_nlp_word_emb_vec brain_nlp_word_em_sim brain_nlp_sentiment_classify brain_nlp_simnet brain_kg_pie_task brain_nlp_wordembedding brain_nlp_simnet_legacy brain_nlp_comment_tag_legacy wise_adapt lebo_resource_base lightservice_public hetu_basic lightcms_map_poi kaidian_kaidian ApsMisTest_Test\\u6743\\u9650 vis-classify_flower bnstest_fasf lpq_\\u5f00\\u653e cop_helloScope ApsMis_fangdi_permission","refresh_token":"25.40eaaf328326baccc4b02e868af8a53d.315360000.1830393677.282335-10438002","session_secret":"sample","expires_in":2592000}'
returnJson = json.loads(content)

token = returnJson['access_token']

KGURL ='https://aip.baidubce.com/rpc/2.0/kg/v1/cognitive/entity_annotation?access_token='+token

http = urllib3.PoolManager()
response = http.request('POST', KGURL, fields={'data':'爆品战略, 39个超级爆品案例的故事与方法'}, headers = {'Content-Type':'application/json'})

pprint.pprint(response.data)

然后就报错了. 错误信息是:

收藏
点赞
0
个赞
共7条回复 最后由西南交大开源回复于2020-02
#9西南交大开源回复于2020-02
#8 罩起一片天回复
可以分享一下你调用的示例代码吗?我遇到了{"error_code":17,"error_msg":"Open api daily request limit reached"}'这样的问题。[图片]
展开

你请求的次数已经到限制了   少请求几次看看

0
#8罩起一片天回复于2020-02
#7 西南交大开源回复
是不是data没传进去

可以分享一下你调用的示例代码吗?我遇到了{"error_code":17,"error_msg":"Open api daily request limit reached"}'这样的问题。

0
#7西南交大开源回复于2020-02
#4 人人心人土土回复
求代码,我也在做实体标注接口,可是代码总是报错

是不是data没传进去

0
#6hefeitest回复于2018-10

http.request都公用的么

0
#5sun03shy回复于2018-05

用不了,什么鬼

0
#4人人心人土土回复于2018-04

求代码,我也在做实体标注接口,可是代码总是报错

0
#2choleraa回复于2018-01
http = urllib3.PoolManager()

data = {'data':'爆品战略, 39个超级爆品案例的故事与方法'}
encoded_data = json.dumps(data)

response = http.request('POST', KGURL, body=encoded_data, headers = {'Content-Type':'application/json'})

换用这种方法已经解决.

 

1
快速回复
TOP
切换版块