UJN图书馆座位自动预约
给想来图书馆学习的同学提供方便,有问题可以问我,想拿去赚钱的就别来了
python
1.下载chrome driver对应版本的浏览器
2.注册超级鹰账号 https://www.chaojiying.com/ 获取软件ID(这里也可以选择别的打码平台)
3.在config.py内填写学号密码姓名座位号等信息
4.在main.py中更改想要预约的阅览室和预约时间
5.写一个crontab,每天定时提前两三分钟执行main.py(会有一个预登陆)
UJN图书馆座位自动预约
UJN图书馆座位自动预约
给想来图书馆学习的同学提供方便,有问题可以问我,想拿去赚钱的就别来了
python
1.下载chrome driver对应版本的浏览器
2.注册超级鹰账号 https://www.chaojiying.com/ 获取软件ID(这里也可以选择别的打码平台)
3.在config.py内填写学号密码姓名座位号等信息
4.在main.py中更改想要预约的阅览室和预约时间
5.写一个crontab,每天定时提前两三分钟执行main.py(会有一个预登陆)
有时候验证码要求点击一个字符,有时候需要点击三个字符,因此感觉不能将点击次数定死为2次。由于要求点击三次验证码的情况比较少,但是早上会出现,因此该段代码还未测试。
verifyClick.py
def revalidation(self):
try:
new_image = self.getImageShear()
click_coordinates = self.uploadPicture(new_image)
for i in range(len(click_coordinates)):
xoffset = int(int(click_coordinates[i][0]) * 1. / ZOOM_RATE)
yoffset = int(int(click_coordinates[i][1]) * 1. / ZOOM_RATE)
ActionChains(self.driver).move_to_element_with_offset(self.ele_iframe, xoffset, yoffset).perform()
# time.sleep(1)
ActionChains(self.driver).click().perform()
time.sleep(random.uniform(1, 3))
logger.info('多个验证码? 在 layui-layer1 元素下,点击坐标:{}, {}'.format(xoffset, yoffset))
selenium截图坐标会受到本地屏幕缩放率的影响(一般笔记本屏幕缩放率会被调为125%),导致最终截图坐标有偏移。建议在截图坐标位置乘缩放率ZOOM_RATE(如果屏幕缩放率为125%,则ZOOM_RATE为1.25)。
verifyClick.py
def getImageShear(self):
try:
self.ele_iframe = self.driver.find_element(By.ID, 'layui-layer1')
logger.info('layui-layer1 元素的坐标:{}'.format(self.ele_iframe.location))
# 验证码区域大小,宽 360px,高 230px
start_x = int(self.ele_iframe.location['x'] * ZOOM_RATE)
start_y = int(self.ele_iframe.location['y'] * ZOOM_RATE)
end_x = int(self.ele_iframe.location['x'] * ZOOM_RATE + 360 * ZOOM_RATE)
end_y = int(self.ele_iframe.location['y'] * ZOOM_RATE + 230 * ZOOM_RATE)
axis = (start_x, start_y, end_x, end_y)
logger.info('layui-layer1 元素下,点选图片坐标:{}'.format(axis))
由于不同屏幕尺寸不同,可能会出现问题,建议将selenium的屏幕尺寸设置为自动最大值。
main.py [96行]
self.browser.maximize_window() # 将浏览器最大化
# self.browser.set_window_size(970, 800)
# self.browser.set_window_size(1240, 800)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.