超星学习通自习室座位预约
本帖最后由 nianboy 于 2022-9-24 20:44 编辑最近有个学弟问我学习通自习室的座位预约能否实现python自动化预约.简单抓包了解一下,发现跟图书馆的预约差不多.于是就写出来了,代码有点简陋,但是又不是不能用手动滑稽.# -*- coding: utf8 -*-
#coder:nianboy
#time:2022-9-14
import requests
import re
import datetime
class ChaoXing:
def __init__(self, seatId):
today = datetime.datetime.now()
self.seatId = seatId
self.nowtime = today.strftime("%Y-%m-%d")
self.lasttime = (today + datetime.timedelta(days=1)).strftime("%Y-%m-%d")
self.headers = {
"User-agent": "Mozilla/4.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36",
}
self.session = requests.session()
def sceen_data(self,id,start_time,end_time,name,pwd):
global today_time
start_time = start_time + "%3A00"
end_time = end_time + "%3A00"
login_api = "https://passport2.chaoxing.com/api/login"
params = {
"name": name,# 学习通账号
"pwd": pwd,# 学习通密码
"verify": "0",
"schoolid": "",
}
self.session.get(login_api, params=params, headers=self.headers)
page_url = "http://office.chaoxing.com/front/third/apps/seat/list?deptIdEnc=cb783d1327681137"
page_resp = self.session.get(url=page_url, headers=self.headers).text
self.pageToken = re.findall(r"'&pageToken='.*?'(.*?)'", page_resp)
url = (
"https://office.chaoxing.com/front/third/apps/seat/select?id="+str(id)+"&day=" + self.nowtime + "&backLevel=2&pageToken=" + str(
self.pageToken) + "&fidEnc=cb783d1327681137"
)
r1 = self.session.get(url=url, headers=self.headers).text
self.token = re.findall(r"token: '(.*?)'", r1)
url = (
"https://office.chaoxing.com/data/apps/seat/submit?roomId="+str(id)+"&startTime="+start_time+"&endTime="+end_time+"&day=" + self.nowtime + "&seatNum=" + str(
self.seatId) + "&captcha=&token=" + str(self.token)
)
page_text = self.session.get(url=url, headers=self.headers).text
if '"success":true' in page_text:
print("预约成功!")
else:
print(page_text + "预约失败!")
if __name__ == "__main__":
chaoxing = ChaoXing(seatId="")# 座位号
chaoxing.sceen_data(id="",start_time="16",end_time="19",name='',pwd='')
#id需要抓包,start_time是预约开始时间,end_time是结束预约时间,name是学习通账号,pwd是学习通密码
点点免费的评分把{:301_997:} 学习了..感谢大佬的教程! 研究一下 本帖最后由 bone 于 2022-11-3 21:25 编辑
预约的url新增了enc 老哥 有时会显示保存失败是什么原因呢 bone 发表于 2022-11-3 09:42
预约的url新增了enc
有没有办法搞掉enc呢 学习了..感谢大佬的教程!
谢谢大佬的分享 老哥太强了!
页:
[1]
2