Python获取企业微信健康上报使用统计
获取access_token
请求方式: GET(HTTPS)
请求地址: https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=ID&corpsecret=SECRET
注:此处标注大写的单词ID和SECRET,为需要替换的变量,根据实际获取值更新。
参数说明:
参数 必须 说明
corpid 是 企业ID,获取方式参考:术语说明-corpid
corpsecret 是 应用的凭证密钥,获取方式参考:术语说明-secret
先将字典形式的数据转化为字符串存入 D:\json1.txt
运行后输出结果:(json1.txt)
C:\Python38\python.exe C:/Users/Administrator/PycharmProjects/untitled/1.py
{"date": "2020-10-27", "jobid": "XXXXXXXXXXXXXXXXXXXXX", "offset": 0, "limit": 10000}
<class ‘dict‘>
{‘errcode‘: 0, ‘errmsg‘: ‘ok‘, ‘answers‘: [{‘id_type‘: 1, ‘userid‘: ‘lilly.li‘, ‘report_values‘: [{‘question_id‘: 1, ‘multi_choice‘: [], ‘text‘: ‘27‘}, {‘question_id‘: 2, ‘multi_choice‘: [], ‘text‘: ‘Admissions ‘}, {‘question_id‘: 3, ‘multi_choice‘: [], ‘text‘: ‘Lilly‘}, {‘question_id‘: 4, ‘multi_choice‘: [], ‘text‘: ‘36.5‘}, {‘question_id‘: 5, ‘multi_choice‘: [], ‘text‘: ‘36.6‘}, {‘question_id‘: 6, ‘multi_choice‘: [1]}, {‘question_id‘: 7, ‘single_choice‘: 1, ‘multi_choice‘: []}, {‘question_id‘: 8, ‘multi_choice‘: [1]}]}, {‘id_type‘: 1, ‘userid‘: ‘lilyxu‘, ‘report_values‘: [{‘question_id‘: 1, ‘multi_choice‘: [], ‘text‘: ‘27/10/20‘}, {‘question_id‘: 2, ‘multi_choice‘: [], ‘text‘: ‘preprep‘}, {‘question_id‘: 3, ‘multi_choice‘: [], ‘text‘: ‘xinyi xu‘}, {‘question_id‘: 4, ‘multi_choice‘: [], ‘text‘: ‘36‘}, {‘question_id‘: 5, ‘multi_choice‘: [], ‘text‘: ‘36‘}, {‘question_id‘: 6, ‘multi_choice‘: [1]}, {‘question_id‘: 7, ‘single_choice‘: 1, ‘multi_choice‘: []}, {‘question_id‘: 8, ‘multi_choice‘: [1]}]}]}
将文件json1.txt导出到output.csv