2 changed files with 67 additions and 0 deletions
@ -0,0 +1,8 @@
@@ -0,0 +1,8 @@
|
||||
# Python 语言版浴室预约脚本 |
||||
|
||||
运行参数: |
||||
- `today` 预约今日的浴室 |
||||
- `tomorrow` 预约明日的浴室 |
||||
- 如果存在形如 `21:00:00` 的参数,则会预约对应时间的浴室(需要确保输入合法) |
||||
- `laravel_session=` 要预约用户的 Token 数据 |
||||
- `debug` 调试模式 |
@ -0,0 +1,59 @@
@@ -0,0 +1,59 @@
|
||||
import re |
||||
from time import sleep, time |
||||
import requests |
||||
import datetime |
||||
import sys |
||||
|
||||
DEBUG = False |
||||
|
||||
|
||||
def main(period, token): |
||||
res = requests.post( |
||||
"http://wx.bupt.edu.cn/bathroom/submit", |
||||
data={ |
||||
"period": period |
||||
}, |
||||
headers={ |
||||
"user-agent": "MicroMessenger", |
||||
}, |
||||
cookies={ |
||||
"laravel_session": token |
||||
}, |
||||
) |
||||
|
||||
if DEBUG or res.status_code == 200: |
||||
print(res.text) |
||||
|
||||
print(res.status_code, re.findall(r'<div class="mt-3">学工号: (\d+)</div>', res.text), |
||||
re.findall(r'<div class="alert alert-info">(.*)</div>', res.text)) |
||||
|
||||
return res.status_code == 200 |
||||
|
||||
|
||||
if __name__ == "__main__": |
||||
today = datetime.date.today() |
||||
tomorrow = today+datetime.timedelta(days=1) |
||||
at = today+datetime.timedelta(days=2) |
||||
|
||||
period = "21:00:00" |
||||
token = "" |
||||
|
||||
rePeriod = r'^\d\d:\d\d:\d\d$' |
||||
date = at |
||||
for arg in sys.argv: |
||||
if ("today" == arg): |
||||
date = today |
||||
if ("tomorrow" == arg): |
||||
date = tomorrow |
||||
if re.fullmatch(rePeriod, arg): |
||||
period = arg |
||||
if "laravel_session" in arg: |
||||
token = arg.split("=")[1] |
||||
if arg == "debug": |
||||
DEBUG = True |
||||
print("task:", date, period, "\n", token) |
||||
|
||||
while 1: |
||||
if main("{} {}".format(date, period), token): |
||||
break |
||||
sleep(1) |
Loading…
Reference in new issue