言成言成啊 | Kit Chen's Blog

今日校园实现自动监测并提交签到和查寝

站在巨人的肩膀上,所以该代码全部开源,我也借鉴的大佬的东西,放在第三节致谢。有问题可以在下面进行留言讨论!

博客地址

一、自动每日签到

源码

1.1 思路

  1. 抓包(抓包的流程,可以参照我之前的文章
  2. 每日接口获取最新表单
  3. 通过上步的id获取详细表单
  4. 通过上步获取该表单的选项id

如果整体的思路看不明白,可以参照下面的详细步骤

1.1 获取最新表单

接口

1
/wec-counselor-sign-apps/stu/sign/getStuSignInfosInOneDay

参数

1
{}

返回值

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
{
"code": "0",
"message": "SUCCESS",
"datas": {
"dayInMonth": "2020-09-10",
"codeRcvdTasks": [],
"signedTasks": [],
"unSignedTasks": [{
"stuSignWid": "746210",
"signInstanceWid": "4146", //需要
"signWid": "514213", //需要
"signRate": "1",
"taskType": "4",
"taskName": "一日三签(早签到)",
"senderUserName": "牛逼学院(牛逼老师)",
"signStatus": "2",
"isMalposition": null,
"isLeave": "0",
"leavePcUrl": null,
"leaveMobileUrl": null,
"currentTime": "2020-09-10 08:15",
"singleTaskBeginTime": null,
"singleTaskEndTime": null,
"rateSignDate": "2020-09-10 (周四)",
"rateTaskBeginTime": "05:00",
"rateTaskEndTime": "09:59"
}, {
"stuSignWid": "759720",
"signInstanceWid": "4199",
"signWid": "514234",
"signRate": "1",
"taskType": "4",
"taskName": "一日三签(午签到)",
"senderUserName": "牛逼学院(牛逼老师)",
"signStatus": "2",
"isMalposition": null,
"isLeave": "0",
"leavePcUrl": null,
"leaveMobileUrl": null,
"currentTime": "2020-09-10 08:15",
"singleTaskBeginTime": null,
"singleTaskEndTime": null,
"rateSignDate": "2020-09-10 (周四)",
"rateTaskBeginTime": "10:00",
"rateTaskEndTime": "15:59"
}, {
"stuSignWid": "778325",
"signInstanceWid": "4266",
"signWid": "535128",
"signRate": "1",
"taskType": "4",
"taskName": "一日三签(晚签到)",
"senderUserName": "牛逼学院(牛逼老师)",
"signStatus": "2",
"isMalposition": null,
"isLeave": "0",
"leavePcUrl": null,
"leaveMobileUrl": null,
"currentTime": "2020-09-10 08:15",
"singleTaskBeginTime": null,
"singleTaskEndTime": null,
"rateSignDate": "2020-09-10 (周四)",
"rateTaskBeginTime": "16:00",
"rateTaskEndTime": "22:00"
}],
"leaveTasks": []
}
}

其中我们需要获取signWid514213和signInstanceWid4146

1.2 获取详细信息

接口

1
/wec-counselor-sign-apps/stu/sign/detailSignInstance

参数

1
2
3
4
{
"signWid" : 514213,
"signInstanceWid" : 4146
}

返回值

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
{
"message" : "SUCCESS",
"datas" : {
"latitude" : "",
"singleTaskEndTime" : null,
"catQrUrl" : "https:\/\/cat.cpdaily.com\/erweima",
"singleTaskBeginTime" : null,
"signInstanceWid" : "4146",
"signPhotoUrl" : null,
"signTime" : null,
"senderUserName" : "牛逼学院(牛逼老师)",
"qrCodeRcvdUsers" : [
{
"targetWid" : "91457111",
"targetType" : "4",
"targetName" : "牛逼老师\/19070302",
"targetGrade" : "-1",
"targetDegree" : "-1",
"targetUserType" : "-1"
}
],
"isNeedExtra" : 1,
"signCondition" : 0,
"currentTime" : "2020-09-10 09:33:08",
"taskDesc" : "https:\/\/wecres.cpdaily.com\/counselor\/1018615876819107\/content\/54e503639d0244049c3b85baabe509fc.html",
"signType" : null,
"changeActorName" : "牛逼老师",
"isMalposition" : 0,
"longitude" : "",
"signedStuInfo" : {
"cls" : "20200521",
"major" : "改变世界专业-牛逼",
"dept" : "牛逼学院",
"sex" : "男",
"mobile" : null,
"nation" : "-",
"userWid" : "1017790009",
"userId" : "20200521",
"userName" : "雷军",
"malposition" : null,
"extraFieldItemVos" : [
{
"fieldIndex" : 0,
"extraDesc" : "",
"extraFieldItemWid" : "",
"extraTitle" : "体温",
"extraFieldItem" : null,
"isExtraFieldOtherItem" : "0",
"isAbnormal" : "0"
},
{
"fieldIndex" : 0,
"extraDesc" : "",
"extraFieldItemWid" : "",
"extraTitle" : "身体是否异常",
"extraFieldItem" : null,
"isExtraFieldOtherItem" : "0",
"isAbnormal" : "0"
}
],
"schoolStatus" : null,
"stuDormitoryVo" : {
"sex" : "",
"area" : "",
"building" : "",
"unit" : "",
"room" : ""
},
"grade" : "2019级"
},
"extraFieldItemVos" : [

],
"changeTime" : null,
"taskType" : "4",
"photograph" : [

],
"signRate" : "1",
"isPhoto" : 0,
"signAddress" : null,
"rateTaskEndTime" : "09:59",
"taskName" : "一日三签(早签到)",
"leaveAppUrl" : "\/wec-counselor-leave-apps\/leave\/home\/index.html",
"isAllowUpdate" : false,
"signMode" : 0,
"rateTaskBeginTime" : "05:00",
"signStatus" : "2",
"signPlaceSelected" : [
{
"address" : "只有野鸡学校才用这个流氓app(北界王西区)",
"radius" : 520,
"longitude" : "125.398185",
"placeWid" : null,
"creatorUserWid" : null,
"creatorName" : null,
"wid" : null,
"latitude" : "44.001709",
"currentStatus" : null,
"isShare" : null,
"creatorUserId" : null
},
{
"address" : "只有野鸡学校才用这个流氓app(北界王东区)",
"radius" : 500,
"longitude" : "125.40993457956229",
"placeWid" : null,
"creatorUserWid" : null,
"creatorName" : null,
"wid" : null,
"latitude" : "44.00262969203334",
"currentStatus" : null,
"isShare" : null,
"creatorUserId" : null
},
{
"address" : "只有野鸡学校才用这个流氓app(南界王校区)",
"radius" : 400,
"longitude" : "125.296568",
"placeWid" : null,
"creatorUserWid" : null,
"creatorName" : null,
"wid" : null,
"latitude" : "43.859918",
"currentStatus" : null,
"isShare" : null,
"creatorUserId" : null
}
],
"rateSignDate" : "2020-09-10 (周四)",
"extraField" : [
{
"hasOtherItems" : 0,
"title" : "体温",
"extraFieldItems" : [
{
"isSelected" : null,
"value" : null,
"content" : "37.3度以下",
"isOtherItems" : 0,
"wid" : 499882,//获取
"isAbnormal" : false
},
{
"isSelected" : null,
"value" : null,
"content" : "37.3度及以上",
"isOtherItems" : 0,
"wid" : 499883,
"isAbnormal" : true
}
],
"description" : "",
"wid" : 211814
},
{
"hasOtherItems" : 1,
"title" : "身体是否异常",
"extraFieldItems" : [
{
"isSelected" : null,
"value" : null,
"content" : "健康",
"isOtherItems" : 0,
"wid" : 499884,//获取
"isAbnormal" : false
},
{
"isSelected" : null,
"value" : null,
"content" : "感冒",
"isOtherItems" : 0,
"wid" : 499885,
"isAbnormal" : false
},
{
"isSelected" : null,
"value" : null,
"content" : "发烧",
"isOtherItems" : 0,
"wid" : 499886,
"isAbnormal" : false
},
{
"isSelected" : null,
"value" : null,
"content" : "咳嗽",
"isOtherItems" : 0,
"wid" : 499887,
"isAbnormal" : false
},
{
"isSelected" : null,
"value" : null,
"content" : "其它",
"isOtherItems" : 1,
"wid" : 499888,
"isAbnormal" : false
}
],
"description" : "",
"wid" : 211815
}
],
"downloadUrl" : "https:\/\/img.cpdaily.com\/ldy\/index.html"
},
"code" : "0"
}

获取我需要的两个参数,体温选项499882和身体是否异常选项499884

1.3 模拟提交

最后通过上面步骤获取到的4146,499882,499884以及自定义的地址,进行签到

接口

1
/wec-counselor-sign-apps/stu/sign/submitSign

参数

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
{
"abnormalReason": "",
"position": "你的地址",
"longitude": 你的经度,
"isNeedExtra": 1,
"latitude": 你的纬度,
"isMalposition": 0,
"extraFieldItems": [{
"extraFieldItemWid": 499882,
"extraFieldItemValue": "37.3度以下"
},
{
"extraFieldItemWid": 499884,
"extraFieldItemValue": "健康"
}
],
"signInstanceWid": "4146",
"signPhotoUrl": ""
}

返回值

1
2
3
4
5
6
7
8
{
"message" : "SUCCESS",
"datas" : {
"signedStuInfo" : null,
"signInstanceWid" : "4146"
},
"code" : "0"
}

1.4 运行结果

二、自动每日查寝

源码

2.1 思路

  1. 抓包(抓包的流程,可以参照我之前的文章
  2. 每日接口获取最新表单
  3. 通过上步的id获取详细表单
  4. 通过上步获取该表单的选项id

2.2 接口

获取最新查寝

1
/wec-counselor-attendance-apps/student/attendance/getStuAttendacesInOneDay

获取详细查寝

1
/wec-counselor-attendance-apps/student/attendance/detailSignInstance

提交查寝

1
/wec-counselor-attendance-apps/student/attendance/submitSign

2.3 随机图片

今日校园的图片,是存储到了阿里云,阿里云有官方开源的sdk,支持各种语言,自己去下相应的sdk来实现上传即可。

阿里云对象存储OSS功能文档

当然,你也可以尝试用代码实现自动往阿里云提交,但是我还是觉得太麻烦,就放弃了。

我采用的方法,是一次性上传多张照片,然后写了一个随机函数返回照片

提交查寝时的参数

1
2
3
4
5
6
7
8
9
10
{
"signInstanceWid": "null",
"longitude": "null",
"latitude": "null",
"isMalposition": "null",
"abnormalReason": "null",
"signPhotoUrl": "null", //这个地方的图片链接,原本我以为可以存放自己服务器照片,后来发现不行,有域名验证
"position": "null",
"qrUuid": "null"
}

三、获取今日校园阿里云oss账号

3.1 前言

10月22日,学校换了新的签到,要拍照。

在提交今日校园照片的时候,无意间抓包到一系列数据,然后,看了阿里云oss的文档之后,顿时明白了许多。

终于知道为啥好多人挤破头颅都要去阿里了。

阿里,就是牛逼,就连上传的所有可能用到的比较人性化的功能(比方说上传进度条功能),都给整完了。

就连我这种菜鸡,都能拿来就可以用。

我曾经听过某大佬说,真正的开发者,写的代码,不仅条理清楚,还通俗易懂。这用来形容阿里再合适不过了。

这是不是就是真正的宗师境界呢?

原谅我太过激动,这也更让我坚定了,要努力学习,进大厂的愿望

3.2 正题

今日校园获取阿里云OSS的接口

1
/wec-counselor-sign-apps/stu/sign/getStsAccess

请求头中携带自己的cookie

获取如下信息,然后用id、secret、token,再结合阿里开源

1
2
3
4
5
6
7
8
9
10
11
12
13
{
"code": "0",
"datas": {
"accessKeyId": "STS.NV47ZBrGJfjlsj97t7VKWepMJvc",
"accessKeySecret": "6ZdSLF6T3JPCbQgqd3mTcqzbEh987829gksCaFxsdxdYK",
"securityToken": "CAIShAN1q6Ft5B2yfSjIr5WBfOD2n5hrgfufR235nFYeW+pcoo/dgTz228gnsibhnhsPw1m2xT6/cTlr0qEsIVGxybMpcutsoGqFP5JtKZ4pQdXmbqNdv3d1KIAjvXgeUFCoeQFaEME5XAQlTAkTAJK9KYERypQ12iN7CQlJdjda55dwKkbD1AdtU0Qwx5s501OGf2P/SgOQKI523LFxhQpxZbg2Fy4rjdusqH8UjygVn31uIyrYb8KYTGCs53J8VbUsyp5OVsarGjoClL8Epj/qBskIlZ/SvGptiHH2RJ5xKPP4iz9cZ0fit4fbQdEaxJp+Tn774a3NbejIPq0R1AEPhIWiDEPuCazdDDBfmiO6ReF9PyMG+f1cuUZNun8VFmQwpCbV4aJYp+dSMuUUJ9E2GCEML9pgCWODXEYrOezaQ73aByy1jV5teQLzCNOe7Ejn5HasRtNx1wbUFKhjGwI7V1eghNYk5hAK2OUYJwYRZRpKXlpwTOUTd6yXVarykzhQceaE91GoABUp6SSSSKU/bJ1rJtD536UCvZcYvsdl9eaDRwkSdFJhLlmd/jC6wpk1NUdqkDbRCs87xwfPZrdfL6AJXRxN0bXIR79q4M9s7tlqes+5iCDaXwsk5/MhIRE+asN6AM9YzOjlu2uftrxyvUsVqMbkBz8QCF+KrdLnSzvTQr1K+LdJQ\u003d",
"expiration": "2020-10-22T14:53:12Z",
"endPoint": "oss-cn-hangzhou.aliyuncs.com",
"bucket": "wecloud-res",
"fileName": "counselor/101820526o268269/content/2085lksj2jgwjoihggsljh.png"
},
"message": "SUCCESS"
}

此处我也遇到了很多问题,比方说有token经常报错不对,那就继续抓包,在上传照片的请求体重,会获得x-oss-security-token

再将token换成x-oss-security-token即可登录今日校园oss,当然,这并不是永久有效的,但是依然有最高权限,比方说删除之类~

注意:

不要乱删除内容哦~

附张成功登录oss之后的图

四、致谢

  1. ZimoLoveShuang
发布:2020-09-10 09:12:07
修改:2020-10-23 12:37:09
链接:https://meethigher.top/blog/2020/cpdaily-sign/
标签:java open 
付款码 捐助 分享
翻墙之后才能评论哦
阅读量