当前位置:网站首页>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 .
边栏推荐
- On Governance and innovation | the openanolis sub forum of the 2022 open atom global open source summit was successfully held
- 【vulnhub】presidential1
- Baidu map API adds information window circularly. The window only opens at the last window position and the window information content is the same solution
- How to realize more multimedia functions through the ffmpeg library and NaPi mechanism integrated in openharmony system?
- php 日期计算操作处理,当前日期加一天和指定日期减一天
- 太赞了!京东研发一哥力荐的高可用网站构建技术PDF,备好水,慢慢啃
- What if the instruction set umi2 is missing? PTK installation cannot be carried out
- 缺少指令集umi2 怎么办?ptk方式安装无法进行
- Zhou Hongyi talks about Internet thinking: users, not customers
- With the continuous waves of infringement, the U.S. patent and trademark office began to study the impact of NFT on copyright
猜你喜欢

Newly released, the domestic ide developed by Alibaba is completely open source

Kafaka丢消息吗

分布式定时器

新零售电商O2O模式解析

腾讯二面:@Bean 与 @Component 用在同一个类上,会怎么样?

金山云冲刺港股拟双重主要上市:年营收90亿 为雷军力挺项目

Developing NES game (cc65) 07 and controller with C language

Baidu map API adds information window circularly. The window only opens at the last window position and the window information content is the same solution

Implementation method of mouse hover, click and double click in ue4/5

Top level "redis notes", cache avalanche + breakdown + penetration + cluster + distributed lock, Nb
随机推荐
金九银十 再不卷就来不及了
Tencent two sides: @bean and @component are used in the same class, what will happen?
ViewPager2+Fragment
Developing NES game (cc65) 07 and controller with C language
Anhui Jingzhun: Beidou satellite synchronous clock | Beidou synchronous clock | NTP network clock server
Zadig v1.13.0 believes in the power of openness, and workflow connects all values
PHP时间戳相减转化为天小时分秒
Live: never believe that suffering is worth it. Suffering is suffering
Baidu map API adds information window circularly. The window only opens at the last window position and the window information content is the same solution
Not optimistic about Apple making AR, Luo Yonghao: I'll do it myself
SuperMap arsurvey license module division
用C语言开发NES游戏(CC65)05、调色板
Uninstall Navicat: genuine MySQL official client, really fragrant!
QT writing IOT management platform 42 data query export print
【vulnhub】Raven2
华为发布HarmonyOS 3及全场景新品,智慧体验更进一步
Implementation method of mouse hover, click and double click in ue4/5
To build agile teams, these methods are indispensable
Redis实现分布式锁
Top level "redis notes", cache avalanche + breakdown + penetration + cluster + distributed lock, Nb