当前位置:网站首页>Library automatic reservation script
Library automatic reservation script
2022-07-28 12:37:00 【wechannn】
Preface
This summer vacation , Having not chosen to stay in school, I resolutely chose to go home . Thinking of going home and lying flat , Occasionally, I can often go City Library volume .
However , Because of the requirements of epidemic prevention and control, you need to make an appointment one day in advance to enter the Library . Of course, we must actively cooperate and abide by the regulations .
however , The reserved opening hours of the library are every morning 6 O 'clock , As the wave of the Internet, of course ... Don't get up so early .
So when I got up and opened the system to make an appointment, I found 
As a Diligent and studious Of Excellent college students , Of course, you can't be defeated by this little difficulty , So there is As the title . Get on the train !!!
Grab the bag

The reservation system of the municipal library is established in WeChat official account Upper .
Here is the first pit , This system can only be accessed on wechat clients , But not in edge、Firefox、Chrome Wait for the browser to access directly .
One solution is to access the wechat developer tool to capture packets , But I am Ubuntu The system of , Wechat developer tools haven't been released yet Linux edition ( Bad review ), We have to stop .
The second scheme is adopted here , Grab bags on your mobile phone ,iOS and Android Search all major packet capturing tools by yourself . Grab post and get Requested json Format data packets for parsing .
analysis
According to the analysis of packet capturing results ,subLibId and scheduleId Of title They are the number of the library and the number of the reservation period .
Other information is some equipment account verification information and personal appointment registration information .
simulation
After bag grabbing , Use python Write a code script to simulate the mobile wechat client sending a request to the node of the target server .
I don't say much nonsense , Go straight to the code , For personal information ##### Instead of
import requests
import time
import datetime
import json
# First create url and headers, And then directly request See if it works .
url = 'https://appointment-backend-cdn.dataesb.com/api/appointment/pub_add/'
header = {
"Accept": "application/json, text/plain, */*",
"Accept-Encoding": "gzip, deflate, br",
"Accept-Language": "zh-CN",
"User-Agent": "#####",
"Referer": "https://appointment-users.dataesb.com/",
"unionid": "#####",
"Content-Length": "173",
"Content-Type": "application/json;charset=UTF-8",
"Origin": "https://appointment-users.dataesb.com",
"Sec-Fetch-Dest": "empty",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Site": "same-site",
"Connection": "keep-alive",
"Host": "appointment-backend-cdn.dataesb.com"
}
Id = #####
scheduleId_t = #####
def re_exe(inc=20):
global scheduleId_t
while True:
time.sleep(inc)
if datetime.datetime.now().hour == 6:
scheduleId_t += 1
if datetime.datetime.now().hour == 5:
scheduleId_t = #####
post_data = {
"subLibId": Id,
"scheduleId": scheduleId_t,
"children": 0,
"card": "#####",
"cardType": "IDCARD",
"name": "#####",
"phone": "#####",
"childrenConfig": True,
"code": ""
}
time_str_13 = int(float(time.time()) * 1000) # Create timestamps
param = {
"timestamp": time_str_13,
"callback": "#####"
}
# Then execute it like this
if datetime.datetime.now().hour == 6:
r1 = requests.post(url, json=post_data, headers=header, params=param, verify=False)
print(scheduleId_t)
print(r1.json())
re_exe(20)
Try to run , And print out the result of the appointment . return 200, And you can see the printed appointment results in the log , Perfect solution .
END
The script code is done , It's impossible to keep 24 Leave the computer running for hours . So we need a server to do it , It happens that my one hasn't expired yet . Timing task ,emmm Not so much ...
So let the program run in the server all the time , The logic of program execution is continuous loop execution , At the same time, the time function is used . The above code sets 6'o clock Automatically make an appointment for me every time I arrive 20 second Ask for once , Prevent him from exploding his database too often and being found by him ...
Be careful , because scheduleId_t It may be changed due to the setting of the background of the library staff , No parsing is sent here get Request to update the running scheduleId_t, Instead, the request is sent by setting the initialization value to increment . Therefore, the initial value needs to be checked irregularly to see whether it needs to be changed .
Use scp command , Transfer the script file to the remote server .
scp Script path Server path
The last pit !!! Terminal exit ssh After connecting to the server remotely , The program executed will also terminate . So you need to run the program persistently on the terminal . Use the following command to make the program run automatically in the background , After the remote connection is closed, it also continues to run .
nohup python3 -u *****.py > log.out 2>&1 &
nohup and **& Double insurance , At the same time, the information printed by the program is saved here journal ** in .
Use the following command to check whether there is a process executor .
ps aux
Call it a day , Next, enjoy the air conditioning of the library during the summer vacation .
边栏推荐
- Developing NES game (cc65) 03 and VRAM buffer with C language
- arduino pro mini ATMEGA328P 连线和点亮第一盏LED(同时记录烧录失败的问题stk500_recv)
- 金九银十 再不卷就来不及了
- 公司在什么情况下可以开除员工
- DIY system home page, your personalized needs PRO system to meet!
- Analysys analysis: focus on users, improve the user experience of mobile banking, and help the growth of user value
- 新东方单季营收5.24亿美元同比降56.8% 学习中心减少925间
- Foam exploded three times, why did Luo Yonghao put all his eggs in one basket to do ar?
- Anhui Jingzhun: Beidou satellite synchronous clock | Beidou synchronous clock | NTP network clock server
- MySQL之知识点(十三)
猜你喜欢

要想组建敏捷团队,这些方法不可少

恋爱男女十禁

GMT安装与使用

QT writing IOT management platform 42 data query export print

AVL树(平衡搜索树)

Uninstall Navicat: genuine MySQL official client, really fragrant!

To build agile teams, these methods are indispensable

laravel表单数据验证

Zadig v1.13.0 believes in the power of openness, and workflow connects all values

Is it overtime to be on duty? Take up legal weapons to protect your legitimate rights and interests. It's time to rectify the working environment
随机推荐
Is it difficult for cloud native machine learning to land? Lingqueyun helps enterprises quickly apply mlops
SQL injection less23 (filter comment)
DIY system home page, your personalized needs PRO system to meet!
数字经济时代的开源数据库创新 | 2022 开放原子全球开源峰会数据库分论坛圆满召开
Come to tdengine Developer Conference and have an insight into the future trend of data technology development
SQL injection less26 (filter spaces and comments, and use error injection without spaces)
Marketing play is changeable, and understanding the rules is the key!
Top level "redis notes", cache avalanche + breakdown + penetration + cluster + distributed lock, Nb
用C语言开发NES游戏(CC65)07、控制器
用arduino开发ESP8266 搭建开发环境
PHP时间戳相减转化为天小时分秒
laravel表单数据验证
[Nuxt 3] (十二) 项目目录结构 3
Distributed session solution
【vulnhub】presidential1
用C语言开发NES游戏(CC65)02、什么是v-blank?
缺少指令集umi2 怎么办?ptk方式安装无法进行
用C语言开发NES游戏(CC65)11、Metatiles
On Governance and innovation | the openanolis sub forum of the 2022 open atom global open source summit was successfully held
新零售电商O2O模式解析