def download_comments_terms(username, password):
userpass = '%s:%s' % (username, password)
auth_encoded = base64.encodebytes(userpass.encode('ascii'))[:-1]
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
req = Request(TERM_API_COMMENTS)
req.add_header('Authorization', 'Basic %s' % str(auth_encoded, 'utf-8'))
response = urlopen(req, context=ctx)
str_response = response.read().decode('utf-8')
j = json.loads(str_response)
return {str(script(_t["IEML"]["value"])) : {
"comment": _t["commentaire_sur_terme"],
"drupal_nid": _t["Nid"]
} for _t in j}
评论列表
文章目录