问题
I am trying to use the IBM personality insights service inside a for loop.
def generateToken(username, password):
r = requests.get("https://gateway.watsonplatform.net/authorization/api/v1/token?url=https://gateway.watsonplatform.net/personality-insights/api", auth=(username, password))
if r.status_code == requests.codes.ok:
return r.text
def personalityRequest(text, token):
base_url='https://gateway.watsonplatform.net/personality-insights/api/v3/profile?version=2017-08-17&consumption_preferences=true&raw_scores=true'
headers = {'X-Watson-Authorization-Token': token, 'Content-Type': 'text/plain'}
r = requests.post(base_url, headers=headers, data={'body': text})
return r.text
token = generateToken('#username', '#password')
for user in range(0,user_data.shape[0]):
user_data["user_personality"][user] = personalityRequest(user_data["user_preferences"][user], token)
The user_data
is a panda dataframe with around 80 observations and user_preferences
is a column with the user text.
When I run the above code I get proper responses for around 30 to 40 users and then it gives me below error.
SSLError: ("bad handshake: Error([('SSL routines',
'ssl3_get_server_certificate', 'certificate verify failed')],)",)
来源:https://stackoverflow.com/questions/45809208/ssl-error-ibm-watson-personality-insights-python