Skip to content

Commit

Permalink
Update 学习通实习打卡签到.py
Browse files Browse the repository at this point in the history
Fix
  • Loading branch information
WAADRI authored Mar 6, 2024
1 parent 8dc1e8d commit 86a79af
Showing 1 changed file with 54 additions and 43 deletions.
97 changes: 54 additions & 43 deletions 学习通实习打卡签到.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
session = requests.session()
res = session.post('https://passport2.chaoxing.com/api/login?name={}&pwd={}&schoolid={}&verify=0'.format(username, password, schoolid), headers=headers).json()
if res["result"]:
res = session.get("http://cqcet.dgsx.chaoxing.com/form/mobile/signIndex", headers=headers)
res = session.get("https://www.dgsx.chaoxing.com/form/mobile/signIndex", headers=headers)
txt = res.text
if txt != "您还没有被分配实习计划。":
if "用户登录状态异常,请重新登录!" not in txt:
Expand All @@ -44,54 +44,65 @@
"allowOffset": allowOffset,
"signSettingId": signSettingId
}
res = session.post("http://cqcet.dgsx.chaoxing.com/form/mobile/saveSign", headers=headers, data=data)
res = session.post("https://www.dgsx.chaoxing.com/form/mobile/saveSign", headers=headers, data=data)
print(res.text)
else:
print("登录失败,请检查用户名密码后重试")
else:
res = session.get("https://www.dgsx.chaoxing.com/mobile/clockin/show", headers=headers)
txt = res.text
if res.status_code == 200:
if "用户登录状态异常,请重新登录!" not in txt:
clockinId = re.search(r'<input id="clockinId" type="hidden" value="(.*)">', txt, re.I).groups()[0]
recruitId = re.search(r'<input type="hidden" id="recruitId" value="(.*)" />', txt, re.I).groups()[0]
pcid = re.search(r'<input type="hidden" id="pcid" value="(.*)" />', txt, re.I).groups()[0]
pcmajorid = re.search(r'<input type="hidden" id="pcmajorid" value="(.*)" />', txt, re.I).groups()[0]
address = address
geolocation = location
remark = remark
should_bntover = re.search(r'''<dd class="should_bntover" selid="(.*)" workStart='(.*)' workEnd='(.*)'>''', txt, re.I).groups()
workStart = should_bntover[1]
workEnd = should_bntover[2]
allowOffset = re.search(r'<input type="hidden" id="allowOffset" value="(.*)"/>', txt, re.I).groups()[0]
offduty = 0
changeLocation = re.search(r'<input type="text" name="location" id="location" value="(.*)" hidden/>', txt, re.I).groups()[0]
if re.search(r'<input id="workLocation" type="hidden" >', txt, re.I) is None:
offset = re.search(r'<input id="workLocation" type="hidden" value="(.*)">', txt, re.I).groups()[0]
resp = session.get("https://i.chaoxing.com/base/cacheUserOrg", headers=headers).json()
is_find = False
for d in resp["site"]:
fid = str(d["fid"])
session.cookies.set("wfwfid", fid)
res = session.get("https://www.dgsx.chaoxing.com/mobile/clockin/show", headers=headers)
txt = res.text
if res.status_code == 200:
if "alert('请先登录');" in txt:
continue
if "用户登录状态异常,请重新登录!" not in txt:
clockinId = re.search(r'<input id="clockinId" type="hidden" value="(.*)">', txt, re.I).groups()[0]
recruitId = re.search(r'<input type="hidden" id="recruitId" value="(.*)" />', txt, re.I).groups()[0]
pcid = re.search(r'<input type="hidden" id="pcid" value="(.*)" />', txt, re.I).groups()[0]
pcmajorid = re.search(r'<input type="hidden" id="pcmajorid" value="(.*)" />', txt, re.I).groups()[0]
address = address
geolocation = location
remark = remark
should_bntover = re.search(r'''<dd class="should_bntover" selid="(.*)" workStart='(.*)' workEnd='(.*)'>''', txt, re.I).groups()
workStart = should_bntover[1]
workEnd = should_bntover[2]
allowOffset = re.search(r'<input type="hidden" id="allowOffset" value="(.*)"/>', txt, re.I).groups()[0]
offduty = 0
changeLocation = re.search(r'<input type="text" name="location" id="location" value="(.*)" hidden/>', txt, re.I).groups()[0]
if re.search(r'<input id="workLocation" type="hidden" >', txt, re.I) is None:
offset = re.search(r'<input id="workLocation" type="hidden" value="(.*)">', txt, re.I).groups()[0]
else:
offset = "NaN"
data = {
"id": clockinId,
"type": 0,
"recruitId": recruitId,
"pcid": pcid,
"pcmajorid": pcmajorid,
"address": address,
"geolocation": geolocation,
"remark": remark,
"workStart": workStart,
"workEnd": workEnd,
"images": "",
"allowOffset": allowOffset,
"offset": offset,
"offduty": offduty,
"changeLocation": changeLocation
}
res = session.post("https://www.dgsx.chaoxing.com/mobile/clockin/addclockin2", headers=headers, data=data)
print(res.text)
is_find = True
break
else:
offset = "NaN"
data = {
"id": clockinId,
"type": 0,
"recruitId": recruitId,
"pcid": pcid,
"pcmajorid": pcmajorid,
"address": address,
"geolocation": geolocation,
"remark": remark,
"workStart": workStart,
"workEnd": workEnd,
"images": "",
"allowOffset": allowOffset,
"offset": offset,
"offduty": offduty,
"changeLocation": changeLocation
}
res = session.post("https://www.dgsx.chaoxing.com/mobile/clockin/addclockin2", headers=headers, data=data)
print(res.text)
print("登录失败,请检查用户名密码后重试")
else:
print("登录失败,请检查用户名密码后重试")
else:
print("您貌似并没有实习打卡任务")
if is_find is False:
print("您貌似并没有实习打卡任务")
else:
print("登录失败,请检查您的用户名密码是否正确")

0 comments on commit 86a79af

Please sign in to comment.