本文共 1180 字,大约阅读时间需要 3 分钟。
#coding:utf-8
import jsonimport requestsfrom requests.auth import HTTPBasicAuth""" 老师和学生是不同的app_id,学生app_id是xxxx,老师app_id是xxx """if name == 'main':
""" 数据统计API: 新增人数 """urla = 'https://api.zhugeio.com/v2/stat/xxxx?metrics=users&dimensions=$province&dimensions=$city' \ '&conditions={"$birth_day":["between","2018-02-01","2018-03-17"],"$province":["==","黑龙江"]}'""" 学生指标: 登录次数sessions """urlb = 'https://api.zhugeio.com/v2/stat/xxxx?metrics=sessions&dimensions=$province&dimensions=$city' \ '&conditions={"$day":["between","2018-02-01","2018-03-17"]}'""" 用户查询API: 成功完成老师任务(阶梯)"""urlc = 'https://api.zhugeio.com/v2/app_users/xxx/user/infos?conditions={"relation": "and",' \ '"event.成功完成老师任务(阶梯)": {"$day":["between","2018-03-12","2018-03-18"]}' \ '}''''""" 以下是学生指标 url: 登录时长(s) """url = 'https://api.zhugeio.com/v2/stat/xxxx?metrics=avg_session_length&dimensions=$province' \ '&conditions={"$day":["between","2018-02-01","2018-03-17"]}''''r = requests.get(urlc, auth=HTTPBasicAuth("1580137xxxx","xxxxxxxxxxf6d74d1fbf7752a76bfbxxxx")).json()print(r)print(len(r['results']))for ele in r['results']: print(ele)
转载于:https://blog.51cto.com/9283734/2092327