2022-10-07 更新:大概两三个月前易校园改了接口,更简单了,我们只需抓包https://h5.xiaofubao.com/marketing/health/doDetail接口即可,脚本如下:

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
# POST https://h5.xiaofubao.com/marketing/health/doDetail HTTP/1.1",

h = {
# your headers.
}

d = {
# These are your POST data.
# ...
# Delete time & date infomation.
# "createTime": "",
# "createDate": "",
# "updateTime": "",
# ...
}

import requests
from pprint import pformat
requests.packages.urllib3.disable_warnings()
import yagmail

def eMail(email_to, email_title, email_content):
# 邮件用户
mail_user = 'your-email'
# 授权码
mail_key = 'your-email-key'
# smtp服务器
mail_host = 'your-email-smtp-server'
try:
mail_server = yagmail.SMTP(
user=mail_user, password=mail_key, host=mail_host)
mail_server.send(email_to, email_title,
email_content, attachments=None)
mail_server.close()
return True
except Exception as e:
print(e)
return False


response = requests.post("https://h5.xiaofubao.com/marketing/health/doDetail", headers=h, data=d, verify=False)
pdata = pformat(response.json(), indent=4)
print(pdata)
title = ''
if response.json()['success'] == True:
title ='打卡成功'
else:
title = '打卡失败'
eMail('your-email', title, pdata)

每天自动打卡,有点烦了,搜索一番,加上解决了一些问题,现拿出此成熟方案。

安装fiddler4

以前高中用fiddler4,现在新版本不知道为啥变得不会用了,貌似还要交钱了,所以不太推荐。推荐下载老版本fiddler4。请自行搜索,此处不提供下载。

设置fiddler并配置证书

易校园采用https通信,因此需要配置证书。这里先进行软件的设置。安装软件后打开设置:

打开这三个选项:

然后按图中设置,开启代理:

然后电脑开热点,手机连上。查看电脑ip,鼠标放在软件右上角或者terminal中输入ipconfig命令查看:

然后手机进入wifi设置,设置手动代理,ip为电脑ip,端口为8888。再打开浏览器,访问电脑ip:8888(前面设置的代理ip)

点击下面链接下载根ca证书

下载完后进入设置—>安装CA证书,找到下载的.cer证书文件安装。

然后手机先打开易校园主界面。回到fiddler,先清除所有会话:

然后点击健康打卡,将选项都填好,位置加载好后,点击打卡,出现打卡成功页面。

回到fiddler,进入设置取消前面的三个勾。

然后我们先保存所有会话:

然后找到这个会话,查看WebForms和JSON出现如下信息:

然后复制所有JSON:

修改以下脚本:

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
import requests
from requests.api import head
import yagmail

# @author:Du Shun Chang
# @version:1.0
# @date:2021/9/4 20:56
# @Todo:易校园自动打卡
# @qq:1300442386


def eMail(email_to, email_title, email_content):
# 邮件用户
mail_user = '你发邮件的邮件账号。需要开启smtp服务'
# 授权码
mail_key = 'smtp授权码'
# smtp服务器
mail_host = 'smtp.163.com'
try:
mail_server = yagmail.SMTP(
user=mail_user, password=mail_key, host=mail_host)
mail_server.send(email_to, email_title,
email_content, attachments=None)
mail_server.close()
return True
except Exception as e:
print(e)
return False


def DoDetail(json):
# 输入打卡信息
data = json
# 添加打卡信息
data['address'] = '这里填写json信息里locationInfo的值,也就是地址'
# 填写Tokan信息
data['uuToken'] = '填写WebForms中的uuToken值'
# 填写Userid
data['loginUserId'] = '同上'
# 填写学校id
data['loginSchoolCode'] = '同上'
# 填写学校名称
data['loginSchoolName'] = '同上'
# 填写体温信息
data['temperature'] = '36.8'
# 填写打卡地址
data['locationInfo'] = "同第一个"
# 填写经纬度信息
data['longitudeAndLatitude'] = '这里填写json信息里longitudeAndLatitude的值'
requests.packages.urllib3.disable_warnings()
# 请求易校园接口
response = requests.post(
"https://h5.xiaofubao.com/marketing/health/doDetail", headers=headers, data=data, verify=False)
return response.json()

# 获取userid


def GetDetail(userid):
data1 = {'userId': userid}
requests.packages.urllib3.disable_warnings()
response = requests.post(
"https://h5.xiaofubao.com/marketing/health/getDetail", headers=headers, data=data1, verify=False)
return response.json()

# 伪造请求头
if __name__ == '__main__':
headers = {'User-Agent': 'Mozilla/5.0 (Linux; Android 11; Redmi Note 8 Pro Build/RP1A.200720.011; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/83.0.4103.106 Mobile Safari/537.36 Html5Plus/1.0 (Immersed/27.636364) ZJYXYwebviewbroswer ZJYXYAndroid tourCustomer /yunmaapp.NET/2.4.1/848e3836c0a4854a',
'Cookie': 'shiroJID=99e30ac2-e86f-4a68-a058-8c2704237789'}
# 这里改成博客里说明的

data = { # 这里请删除,更换成你的json值中的data键值对,样式应该如此所示,此处信息已被删除。
"schoolCode": "",
"schoolName": "",
"identityType": 1,
"userId": "",
"mobilePhone": "",
"name": "",
"jobNo": "",
"departmentCode": "",
"department": "",
"specialitiesCode": "",
"specialities": "",
"classCode": "",
"className": "",
"provinceCode": '',
"province": "",
"cityCode": '',
"city": "",
"inSchool": 0,
"contactArea": 1,
"isPatient": 1,
"contactPatient": 1,
"linkPhone": "",
"parentsPhone": "",
"createTime": "2020-09-24 21:24:58",
"createDate": "2020-09-24 00:00:00",
"updateTime": "2021-11-20 01:36:34",
"locationInfo": "",
"longitudeAndLatitude": "",
"isSuspected": 1,
"healthStatusNew": "1",
"identitySecondType": "11",
"districtCode": '',
"district": "",
"isFamiliyPatient": 1,
"isCommunityPatient": 1,
"isTodayBack": 1,
"backWay": 6,
"backRemark": "",
"backProvinceCode": '',
"backProvince": "",
"backCityCode": '',
"backCity": "",
"backDistrictCode": '',
"backDistrict": "",
"patientHospital": "",
"isolatedPlace": "",
"country": ""
}



data['uuToken'] = '你的uuToken'
# 填写Userid

json = GetDetail('你的loginUserId')

print(json)
print('======================================================================'*2)
if(json['success'] == True):
json = DoDetail(json['data'])
print(json)

print('======================================================================'*2)

if(json['success'] == True):
eMail(email_to='接收信息的邮箱,推荐qq邮箱',
email_title='健康打卡成功!', email_content=str(json))
print('成功')
else:
eMail(email_to='接收信息的邮箱,推荐qq邮箱',
email_title='健康打卡失败!', email_content=str(json))
print('失败')


如果提示没有yagmail库,请自行pip install yagmail安装。

然后可以给你的服务器添加一个定时任务,每天凌晨自动运行此脚本。

成功示例:

2021-11-22
Contents

⬆︎TOP