Giter Site home page Giter Site logo

ujnlib's Introduction

UJNLib

UJN图书馆座位自动预约

给想来图书馆学习的同学提供方便,有问题可以问我,想拿去赚钱的就别来了

语言

python

使用方法

1.下载chrome driver对应版本的浏览器
2.注册超级鹰账号 https://www.chaojiying.com/ 获取软件ID(这里也可以选择别的打码平台)
3.在config.py内填写学号密码姓名座位号等信息
4.在main.py中更改想要预约的阅览室和预约时间
5.写一个crontab,每天定时提前两三分钟执行main.py(会有一个预登陆)

ujnlib's People

Contributors

user-lwl avatar

Stargazers

 avatar  avatar Battlehare Dig avatar Asuka avatar  avatar  avatar

Watchers

 avatar

Forkers

501686948

ujnlib's Issues

验证码点击数量的问题

有时候验证码要求点击一个字符,有时候需要点击三个字符,因此感觉不能将点击次数定死为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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.