python实现一键体育馆场地、羽毛球场预定功能及其web服务部署(以武汉大学为例)

文章目录

  • 前言
  • 一、实现步骤
  • 二、实现方案
    • 1.引入库
    • 2.登陆模块
    • 3.查询模块
    • 4.下单模块
  • 三、web端实现
  • 四、注意事项

前言

现在手动抢球场真的很难,是时候解放双手了.
Talk is cheap, show me the code.
不想看code也不要紧,直接上我已经做好的服务亦可一键预定https://bookgym.wofost.com/


需要的库:conda 自带库,execjs, xmls

一、实现步骤

这里给大家贴一个前辈的探索,https://blog.csdn.net/baiguikai/article/details/101036360,这边前辈的方案已经过时了,导致无法登陆问题。
新思路:
1、登陆(跳转信息门户; 使用pyexecjs加密密码;获取token;返回登陆运动场预约系统;获取用户ID【不是学号!】)
2、查询空闲场地
3、提交

二、实现方案

1.引入库

代码如下(以武大运动场预约系统为例):

2.登陆模块

代码如下(示例):

思路为跳转信息门户; 使用pyexecjs加密密码;获取token;返回登陆运动场预约系统;获取用户ID【不是学号!】。


3.查询模块

这里在提交订单之前先查询场地是否available,大大降低被ban的几率

    def query(self, sess):        ## retrieve the statusurl = "http://gym.whu.edu.cn/OrderQueryAction!getMPointPeriod"order_params = {    "ggId": self.ggId,    "ffId": self.ffId,    "usrId": self.usrId,    "date": self.orderDate,    "startTime": '00:00:00',    "endTime": '23:59:00'}    result = sess.post(url=url, data=order_params)user_dic = json.loads(result.content)# logger.logInfo(user_dic)## query the target field status# index of order timeif user_dic == -1:    logger.logInfo('Query: order time not open.')    return Falseelse:    indexList = np.arange(0,25) # 9:00 - 21:00     startH = int(self.start_time.split(' ')[-1].split(':')[0])    if int(self.start_time.split(' ')[-1].split(':')[1]) == 0: indexS = (startH-9)*2    else: indexS = (startH-9)*2+1    endH = int(self.end_time.split(' ')[-1].split(':')[0])    if int(self.end_time.split(' ')[-1].split(':')[1]) == 0: indexE = (endH-9)*2    else: indexE = (endH-9)*2+1    openH = int(user_dic[0][0]['startTime'].split(':')[0])    if int(user_dic[0][0]['startTime'].split(':')[1]) == 0: openIndex = (openH-9)*2    else: openIndex = (openH-9)*2+1    indexS -= openIndex    indexE -= openIndex    targetStatusList = user_dic[indexS:indexE]   targetStatus = []    for ts in targetStatusList:     targetStatus.append(ts[int(self.fdId) - self.fdIdStart]['status'])    logger.logInfo('Ordering from {} to {}, status:{}'.format(user_dic[indexS][0]['startTime'],user_dic[来源:真教程
                                                        

声明:本站部分文章及图片转载于互联网,内容版权归原作者所有,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2021年3月26日
下一篇 2021年3月26日

相关推荐