当前位置:网站首页>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 .
边栏推荐
- PHP获取本周所有日期或者最近七天所有日期
- Developing NES games with C language (cc65) 02. What is v-blank?
- 让arduino支持nuvotom新唐
- ViewPager2+Fragment
- Anhui Jingzhun: Beidou satellite synchronous clock | Beidou synchronous clock | NTP network clock server
- Newly released, the domestic ide developed by Alibaba is completely open source
- Tencent two sides: @bean and @component are used in the same class, what will happen?
- SQL injection less26 (filter spaces and comments, and use error injection without spaces)
- 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
- Fusion cloud native, enabling new mileage | 2022 open atom global open source summit cloud native sub forum successfully held
猜你喜欢
随机推荐
Newly released, the domestic ide developed by Alibaba is completely open source
AsiaInfo technology released antdb7.0, a "Telecom grade" core transaction database, to help government and enterprises "trust" to create the future!
Fastjson parses multi-level JSON strings
洪九果品通过聆讯:5个月经营利润9亿 阿里与中国农垦是股东
SuperMap itablet license module division
Solve the PHP prompt warning: division by zero in error
PHP获取本周所有日期或者最近七天所有日期
If you don't roll the golden nine and silver ten, it's too late
Uninstall Navicat: genuine MySQL official client, really fragrant!
Zadig v1.13.0 believes in the power of openness, and workflow connects all values
Brief discussion on open source OS distribution
顶级“Redis笔记”,缓存雪崩+击穿+穿透+集群+分布式锁,NB了
Top level "redis notes", cache avalanche + breakdown + penetration + cluster + distributed lock, Nb
遭受痛苦和创伤后的四种本真姿态 齐泽克
软件架构师必需要了解的 saas 架构设计?
Distributed session solution
Come to tdengine Developer Conference and have an insight into the future trend of data technology development
First in the country! The two standards of "data product registration" formulated by insight technology and Shandong data were officially released
Not optimistic about Apple making AR, Luo Yonghao: I'll do it myself
Developing NES game (cc65) 07 and controller with C language









