首先是新手去官网1 元买:
买完之后访问:
https://console.bce.baidu.com/ai/?fromai=1#/ai/nlp/app/list
然后代码:
# encoding:utf-8
import requests
# 获取网址 https://console.bce.baidu.com/ai/?fromai=1#/ai/nlp/app/list
# Access Key Hczb9XGhGcZ
# Secret Key dGm5ERzvOt
# client_id 为官网获取的AK, client_secret 为官网获取的SK
# encoding:utf-8
import requests
# client_id 为官网获取的AK, client_secret 为官网获取的SK
host = 'https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=Hczb9XGhGcZFaG79nGbosakj&client_secret=vOtFyAl8ts36h8KbbRLB20aGz'
response = requests.get(host)
if response:
print(response.json())
def word_review(text):
'''
文本审核接口
'''
request_url = "https://aip.baidubce.com/rest/2.0/solution/v1/text_censor/v2/user_defined"
params = {"text":text}
access_token = 5.282335-29293935'
request_url = request_url + "?access_token=" + access_token
headers = {'content-type': 'application/x-www-form-urlencoded'}
response = requests.post(request_url, data=params, headers=headers)
if response:
res=response.json()['conclusion']
return res
else:
r="系统错误请稍后再试"
return r
版权声明:本文为pythonyanyan原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。