当前位置:网站首页>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 games with C language (cc65) 04. Complete background
- 洪九果品通过聆讯:5个月经营利润9亿 阿里与中国农垦是股东
- 行业落地呈现新进展 | 2022 开放原子全球开源峰会 OpenAtom OpenHarmony 分论坛圆满召开
- [Nuxt 3] (十二) 项目目录结构 3
- SQL injection LESS18 (header injection + error injection)
- Laravel $object->updated_ At returns the carbon object. How to return the normal time format
- FlexPro软件:生产、研究和开发中的测量数据分析
- Top level "redis notes", cache avalanche + breakdown + penetration + cluster + distributed lock, Nb
- First in the country! The two standards of "data product registration" formulated by insight technology and Shandong data were officially released
猜你喜欢

HMS core audio editing service supports 7 kinds of audio effects to help one-stop audio processing

First in the country! The two standards of "data product registration" formulated by insight technology and Shandong data were officially released

Arduino Pro Mini atmega328p connect and light the first LED (at the same time, record the problem of burning failure stk500_recv)

金九银十 再不卷就来不及了

On Governance and innovation | the openanolis sub forum of the 2022 open atom global open source summit was successfully held

Uninstall Navicat: genuine MySQL official client, really fragrant!

产学研用 共建开源人才生态 | 2022 开放原子全球开源峰会教育分论坛圆满召开

Open source office (ospo) unveils Secrets

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

Several ways to bind controls --butterknife/viewbinding/databinding
随机推荐
FlexPro软件:生产、研究和开发中的测量数据分析
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
易观分析:以用户为中心提升手机银行用户体验,助力用户价值增长
To build agile teams, these methods are indispensable
新东方单季营收5.24亿美元同比降56.8% 学习中心减少925间
用C语言开发NES游戏(CC65)11、Metatiles
Live: never believe that suffering is worth it. Suffering is suffering
奥浦迈生物通过注册:半年营收1.47亿 国寿成达与达晨是股东
洪九果品通过聆讯:5个月经营利润9亿 阿里与中国农垦是股东
PHP时间戳相减转化为天小时分秒
Industry, University, research and application jointly build an open source talent ecosystem | the 2022 open atom global open source summit education sub forum was successfully held
Full analysis of seven classical regression analysis methods
SQL注入 Less18(头部注入+报错注入)
Developing NES games with C language (cc65) 04. Complete background
Why do enterprises need the ability of enterprise knowledge management?
Interpretation of the paper: attention mechanism in medical images
行业落地呈现新进展 | 2022 开放原子全球开源峰会 OpenAtom OpenHarmony 分论坛圆满召开
Exploration on cache design optimization of community like business
遭受痛苦和创伤后的四种本真姿态 齐泽克
AsiaInfo technology released antdb7.0, a "Telecom grade" core transaction database, to help government and enterprises "trust" to create the future!