0%

易班打卡

易班打卡

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

yb = YiBan("15656668696", "mima") # FIXME:账号密码
yb.login()
yb.getHome()
print("登录成功 %s"%yb.name)
yb.auth()


import re
import requests
import util
class YiBan:
# CSRF = "sui-bian-fang-dian-dong-xi" # 随机值 随便填点东西
# COOKIES = {"csrf_token": CSRF} # 固定cookie 无需更改
client = "android"
referer = "http://power.modsdom.com/sccloudV5/LAB1/Index/Index/index"
COOKIES = ""
yb_uid = 38205498
HEADERS = {"Origin": "https://c.uyiban.com", "User-Agent": "yiban"} # 固定头 无需更改

def __init__(self, account, passwd):
self.account = account
self.passwd = passwd
self.session = requests.session()
self.name = ""
self.iapp = ""

def request(self, url, method="get", params=None, cookies=None):
if method == "get":
req = self.session.get(url, params=params, timeout=10, headers=self.HEADERS, cookies=cookies)
else:
req = self.session.post(url, data=params, timeout=10, headers=self.HEADERS, cookies=cookies)
try:
return req.json()
except:
return None
def requestgetdata(self, url, method="get", params=id, headers=""):
if method == "get":
req = self.session.get(url, params=params, timeout=10, headers=self.HEADERS, cookies=self.COOKIES)
else:
req = self.session.post(url, data=params, timeout=10, headers=self.HEADERS, cookies=self.COOKIES)
try:
return req.json()
except:
return None
# 已适配
def login(self):
params = {
"mobile": self.account,
"imei": "0",
"password": self.passwd
}
# 最新不需要加密密码直接登录的接口来自原作者looyeageeB站视频评论用户:破损的鞘翅(bilibili_id:45807603)
r = self.request(url="https://mobile.yiban.cn/api/v3/passport/login", params=params)
if r is not None and str(r["response"]) == "100":
self.access_token = r["data"]["user"]["access_token"]
return r
else:
raise Exception("账号或密码错误")
# 已适配
def getHome(self):
params = {
"access_token": self.access_token,
}
r = self.request(url="https://mobile.yiban.cn/api/v3/home", params=params)
self.name = r["data"]["user"]["userName"]
for i in r["data"]["hotApps"]: # 动态取得iapp号 20201117更新
if i["name"] == "池院晨午晚检":
self.iapp = re.findall(r"(iapp.*)\?", i["url"])[0]
return r

def auth(self):
params = {
"act": self.iapp[0:10],
"v": self.access_token
}
print()
location = self.session.get("http://f.yiban.cn/iapp/index",params=params,
allow_redirects=False).headers.get("Location")
if location is None:
raise Exception("该用户可能没进行校方认证,无此APP权限")
verifyRequest = re.findall(r"verify_request=(.*?)&", location)[0]

Cookie = self.session.get("http://power.modsdom.com/sccloudV5/LAB1/Index/login/yibanLogin/customer_id/48/role_tag/TEMP_REPORT?verifyRequest=%s&yb_uid=%s" % (verifyRequest, self.yb_uid),
allow_redirects=False).headers.get("Set-Cookie")
self.COOKIES = {"PHPSESSID": Cookie[10:-8]}
self.HEADERS = {
"Host": "power.modsdom.com",
"Connection": "keep-alive",
"Accept": "application/json, text/plain, */*",
"User-Agent": "Mozilla/5.0 (Linux; Android 8.1.0; 16 X Build/OPM1.171019.026; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/65.0.3325.110 Mobile Safari/537.36 yiban_android",
"Content-Type": "application/x-www-form-urlencoded",
"Referer": "http://power.modsdom.com/sccloudV5/LAB1/Index/Index/index",
"Accept-Encoding": "gzip, deflate",
"Accept-Language": "zh-CN,en-US;q=0.9",
"X-Requested-With": "com.yiban.app",
}
self.session.headers.update(self.HEADERS)
self.session.cookies.update(self.COOKIES)

customer_id = 48
result_auth1 = requests.get(
"http://power.modsdom.com/sccloudV5/index.php/LAB1/User/TempAjax/getMyTempInfo?customer_id=%s" % (
customer_id), headers=self.HEADERS, cookies=self.COOKIES)
result_auth = self.request(
"http://power.modsdom.com/sccloudV5/index.php/LAB1/User/TempAjax/getMyTempInfo?customer_id=%s" % (customer_id),cookies=self.COOKIES)
print(result_auth1.text)
data_url = result_auth["data"].get("Data")
if data_url is not None: # 授权过期
result_html = self.session.get(url=data_url, headers=self.HEADERS,
cookies={"loginToken": self.access_token}).text
re_result = re.findall(r'input type="hidden" id="(.*?)" value="(.*?)"', result_html)
post_data = {"scope": "1,2,3,"}
for re_i in re_result:
post_data[re_i[0]] = re_i[1]
usersure_result = self.session.post(url="https://oauth.yiban.cn/code/usersure",
data=post_data,
headers=self.HEADERS, cookies={"loginToken": self.access_token})
if usersure_result.json()["code"] == "s200":
return self.auth()
else:
return False
else:
return True

def getUncompletedList(self):
params = {
"CSRF": self.CSRF,
"StartTime": util.get_today(),
"EndTime": util.get_time()
}
return self.request("https://api.uyiban.com/officeTask/client/index/uncompletedList", params=params,
cookies=self.COOKIES)

def getCompletedList(self):
params = {
"CSRF": self.CSRF,
"StartTime": util.get_7_day_ago(),
"EndTime": util.get_time()
}
return self.request("https://api.uyiban.com/officeTask/client/index/completedList", params=params,
cookies=self.COOKIES)

def getTaskDetail(self, taskId):
return self.request(
"https://api.uyiban.com/officeTask/client/index/detail?TaskId=%s&CSRF=%s" % (taskId, self.CSRF),
cookies=self.COOKIES)

def submit(self, data, extend, wfid):
params = {
"data": data,
"extend": extend
}
return self.request(
"https://api.uyiban.com/workFlow/c/my/apply/%s?CSRF=%s" % (wfid, self.CSRF), method="post",
params=params,
cookies=self.COOKIES)

def getShareUrl(self, initiateId):
return self.request(
"https://api.uyiban.com/workFlow/c/work/share?InitiateId=%s&CSRF=%s" % (initiateId, self.CSRF),
cookies=self.COOKIES)