XJTU_抢床位
#
import requests
import json
import re
from tqdm import tqdm
import time
import os
def 收藏():
t=str(int(round(time.time() * 1000)))
url='http:///appdm/freshman/collect/getBedCollectList?t='+t+'&personsn='+学号+'÷Id='+设备号+'&modelId=dm'
data={
't': t,
'personsn': 学号,
'divideId': 设备号,
'modelId': 'dm'
}
headers={
'Accept': 'application/json, text/plain, */*',
'Accept-Encoding': 'gzip, deflate',
'Accept-Language': 'zh-CN,zh;q=0.9',
'Cache-Control': 'no-cache',
'Connection': 'keep-alive',
'Content-Length': '0',
'Cookie': cookie,
'Host': 'housing2021.xjtu.edu.cn',
'Origin': 'http://housing2021.xjtu.edu.cn',
'Pragma': 'no-cache',
'token': token,
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1',
}
rep_shou = requests.post(url=url, data=data, headers=headers)
rep_stext=rep_shou.text
#id_data=json.loads(rep.text)
return rep_stext
def 抢床位():
t=int(round(time.time() * 1000))
url='http:///appdm/freshman/bunk/distributeBed'
data={
"t":t,
"personsn":学号,
"bedPlaceCode":bedPlaceCode,
"divideId":设备号,
"aircondition":"",
"beddingInfo":beddingInfo,
"bedCodes":bedCodes,
"chooseWay":2
}
print(data)
headers={
'Accept': 'application/json, text/plain, */*',
'Accept-Encoding': 'gzip, deflate',
'Accept-Language': 'zh-CN,zh;q=0.9',
'Cache-Control': 'no-cache',
'Connection': 'keep-alive',
'Cookie':cookie,
'Host': 'housing2021.xjtu.edu.cn',
'Origin': 'http://housing2021.xjtu.edu.cn',
'Pragma': 'no-cache',
'token':token,
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1',
}
#一定要json提交
rep_qiang = requests.post(url=url, json=data, headers=headers)
#id_data=json.loads(rep.text)
return rep_qiang.text
def 解析_床位(c_rep_text):
global json_c
c_stext=c_rep_text
c_stext=c_stext.replace(th1,'')
c_stext=c_stext.replace(th3,'')
c_stext=c_stext.replace(th2,'$')
json_c=json.loads(c_stext)
for i in range(5):
print('序号'+str(i+1)+json_c['bedCollects'][i]['name'])
i=i+1
return True
th1='\"[[\\'
th2='\\\",[\\\"'
th3='\\\"]]]'
#这里输入自己的学号
#这里输入自己的设备码 用电脑看
json_c=''
设备号=''
学号=''
cookie=str(input("请输入Cookie:")).strip()
token_id=cookie.split(";")[2]
token=token_id.split("=")[1]
print(token)
rep_stext=收藏()
print(rep_stext)
if(解析_床位(rep_stext)):
xz=int(input('请输入预备床位.....'))
bedCodes=json_c['bedCollects'][xz-1]['bedCodes']
bedPlaceCode=json_c['bedCollects'][xz-1]['code']
beddingInfo=json_c['bedCollects'][xz-1]['beddingInfo'].split("$")[1]
#进行判断时间
while 2>1:
if(int(round(time.time() * 1000))>=1662623999000):
#大于或者等于2022年9月8日 15:59:59
print("时间到了")
qiangcw_fankui=抢床位()
print(qiangcw_fankui)
if '选床还未开始' in qiangcw_fankui:
time.sleep(0.3)
print('继续抢')
qiangcw_fankui=抢床位()
time.sleep(0.3)
elif '他人选中' in qiangcw_fankui:
xz=int(input('请输入预备床位.....'))
bedCodes=json_c['bedCollects'][xz-1]['bedCodes']
bedPlaceCode=json_c['bedCollects'][xz-1]['code']
beddingInfo=json_c['bedCollects'][xz-1]['beddingInfo'].split("$")[1]
qiangcw_fankui=抢床位()
elif '有床位的人' in qiangcw_fankui:
print("抢到了")
break
elif '恭喜' in qiangcw_fankui:
print("抢到了")
break
else:
time.sleep(1)
print("时间还没到"+time.strftime('%Y-%m-%d %H:%M:%S'))
本文来自博客园,作者:安之立吖,转载请注明原文链接:https://www.cnblogs.com/anzhili/p/16696998.html

浙公网安备 33010602011771号