Refer to this article to first calculate the token, and then refer to this article to calculate:
Found that there is no problem when only one record is counted
import json url = 'https://aip.baidubce.com/rpc/2.0/nlp/v1/sentiment_classify?charset=UTF-8 & amp;access_token={}'.format(token) data = {<!-- --> 'text':'This phone is not easy to use' } data = json.dumps(data) res = requests.post(url,data=data) print(res.text)
However, when using the for loop to continuously call the api, the following error is reported:
requests.exceptions.ProxyError: HTTPSConnectionPool(host=’aip.baidubce.com’,
After analysis, it is called too frequently, so every time it is called in the for loop time.sleep(0.2)