python自动打卡
简介
1.推荐使用selenium库+FireFox_linux浏览器+geckodriver驱动+crontab定时,
2.因为某图系统的底层是使用的data存储,cookie存于服务器与服务器之间,又Chrome浏览器在mac和Linux系统下不支持跨域,所以推荐使用FireFox.
3.另外
使用思路
使用服务器,创建三个python3文件,如下代码所示,使用pip安装selenium库,下载FireFox_linux要与驱动的版本号保持一致.然后创建3个执行python文件sh脚本,使用crontab定时执行脚本。
Morning.py
# encoding=utf8
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.firefox.options import Options
import timeclass DailyReport(object):def __init__(self):self.client = Noneself.index_url = 'http://xxx.xxx.net:xxx/#/'self.report_url = 'http://xxx.xxx.net:xxx/#/daily/healthInfo'self.data = [('学号xxx', '密码xxx'),]def login(self, _username, _password):try:fireFoxOptions = Options()fireFoxOptions.add_argument('--headless')self.client = webdriver.Firefox(options=fireFoxOptions)self.client.get(self.index_url)time.sleep(3)username = self.client.find_elements_by_tag_name("input")[0]password = self.client.find_elements_by_tag_name('input')[1]username.send_keys(_username)password.send_keys(_password)submit_button = self.client.find_elements_by_tag_name("button")[0]submit_button.click()except NoSuchElementException:print(self.get_current_time(), ' 提交异常! 打卡失败!')else:time.sleep(2)print(self.get_current_time() + ' ' + '登录成功!')self.client.get(self.report_url)time.sleep(7)daily_healthy = self.client.find_element_by_xpath('//*[@id="pane-0"]/form/button')daily_healthy.click()print('提交按钮已点击')time.sleep(20)daily_confrim = self.client.find_element_by_xpath('/html/body/div[2]/div/div[3]/button[2]')daily_confrim.click()time.sleep(3)print('打卡结束')finally:time.sleep(5)self.client.quit()print('浏览器退出...\n--------------\n')def run(self):for msg in self.data:self.login(msg[0], msg[1])self.post_data()print('Python script completed at ' + self.get_current_time() + '\n--------------\n')# self.loginTest()@staticmethoddef get_current_time():return time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())if __name__ == '__main__':obj = DailyReport()obj.run()
Noon.py
# encoding=utf8
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.firefox.options import Options
import timeclass DailyReport(object):def __init__(self):self.client = Noneself.index_url = 'http://xxx.xxx.net:xxx/#/'self.report_url = 'http://xxx.xxx.net:xxx/#/daily/healthInfo'self.data = [('学号xxx', '密码xxx'),]def login(self, _username, _password):try:fireFoxOptions = Options()fireFoxOptions.add_argument('--headless')self.client = webdriver.Firefox(options=fireFoxOptions)self.client.get(self.index_url)time.sleep(3)username = self.client.find_elements_by_tag_name("input")[0]password = self.client.find_elements_by_tag_name('input')[1]username.send_keys(_username)password.send_keys(_password)submit_button = self.client.find_elements_by_tag_name("button")[0]submit_button.click()except NoSuchElementException:print(self.get_current_time(), ' 提交异常! 打卡失败!')else:time.sleep(2)print(self.get_current_time() + ' ' + '登录成功!')self.client.get(self.report_url)time.sleep(7)noon_Tag = self.client.find_element_by_xpath('//*[@id="tab-1"]')noon_Tag.click()time.sleep(7)daily_healthy = self.client.find_element_by_xpath('//*[@id="pane-1"]/form/button')daily_healthy.click()print('提交按钮已点击')time.sleep(20)daily_confrim = self.client.find_element_by_xpath('/html/body/div[2]/div/div[3]/button[2]')daily_confrim.click()time.sleep(3)print('打卡结束')finally:time.sleep(5)self.client.quit()print('浏览器退出...\n--------------\n')def run(self):for msg in self.data:self.login(msg[0], msg[1])self.post_data()print('Python script completed at ' + self.get_current_time() + '\n--------------\n')# self.loginTest()@staticmethoddef get_current_time():return time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())if __name__ == '__main__':obj = DailyReport()obj.run()
Night.py
# encoding=utf8
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.firefox.options import Options
import timeclass DailyReport(object):def __init__(self):self.client = Noneself.index_url = 'http://xxx.xxx.net:xxx/#/'self.report_url = 'http://xxx.xxx.net:xxx/#/daily/healthInfo' self.data = [('学号xxx', '密码xxx'),]def login(self, _username, _password):try:fireFoxOptions = Options()fireFoxOptions.add_argument('--headless')self.client = webdriver.Firefox(options=fireFoxOptions)self.client.get(self.index_url)time.sleep(3)username = self.client.find_elements_by_tag_name("input")[0]password = self.client.find_elements_by_tag_name('input')[1]username.send_keys(_username)password.send_keys(_password)submit_button = self.client.find_elements_by_tag_name("button")[0]submit_button.click()except NoSuchElementException:print(self.get_current_time(), ' 提交异常! 打卡失败!')else:time.sleep(2)print(self.get_current_time() + ' ' + '登录成功!')self.client.get(self.report_url)time.sleep(7)# 拿到中午标签Night_Tag = self.client.find_element_by_xpath('//*[@id="tab-2"]')Night_Tag.click()time.sleep(7)daily_healthy = self.client.find_element_by_xpath('//*[@id="pane-2"]/form/button')daily_healthy.click()print('提交按钮已点击')time.sleep(20)daily_confrim = self.client.find_element_by_xpath('/html/body/div[2]/div/div[3]/button[2]')daily_confrim.click()time.sleep(3)print('打卡结束')finally:time.sleep(5)self.client.quit()print('浏览器退出...\n--------------\n')def run(self):for msg in self.data:self.login(msg[0], msg[1])self.post_data()print('Python script completed at ' + self.get_current_time() + '\n--------------\n')# self.loginTest()@staticmethoddef get_current_time():return time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())if __name__ == '__main__':obj = DailyReport()obj.run()
python自动打卡相关推荐
- 接龙管家-Python自动打卡
接龙管家-Python自动打卡 首先要用 fillder 抓包小程序: 根据抓包的内容,编写脚本: 在云服务器上设置定时脚本: Autojs版脚本: 云服务器-获取接龙管家token 首先要用 fil ...
- 接龙管家-Python自动打卡(续)获取接龙管家token
获取接龙管家token 前言 条件 代码 碎碎念 前言 之前写了接龙管家的python打卡,但是它的token有效期只有三四天,所以需要经常更换 最后采取的方法是: Selenium 模拟登录网页版接 ...
- python 打卡记录代码_python实现自动打卡的示例代码
自己也百度了一下,然后写的,分为了三个部分,见三段代码 代码:主程序代码 import timefrom selenium import webdriverfrom private_info impo ...
- 安卓手机+python基于abd命令的自动打卡
公司现在采用钉钉打卡机制来考勤,由于下班后会忘记打卡,查询多方资料,思考完以后,根据python写下当前脚本. 一顿神操作之后,发现咦,安卓手机不需要root只需要开启usb调试,配置adb命令以后就 ...
- Python实现钉钉/企业微信自动打卡
每天急匆匆赶地铁上班的时候总会一不小心就会忘记打卡,尤其是软件打卡,那有没有什么办法可以解决忘打卡的问题呢?今天给大家推荐一下一款神器,利用Python实现定时自动打卡. 1 前期工具准备 不用说的P ...
- python之网页自动打卡
想要用python实现自动打卡你需要依靠以下两个第三方库 1.selenium 2.apscheduler 说明一下,我这里默认你已经安装好了python 那么首先你要安装selenium,在cmd. ...
- Python进行网页自动打卡系统
Python进行网页自动打卡系统 安装Python 下载Chromedriver 安装selenium 设置定时自动运行 Python程序 安装Python 可以直接Python官网下载,需要进行路径 ...
- python实现小米手机 dingding 自动打卡
我所使用的为python 3.9.2, 这个可以自己去下载 首先要对手机进行设置 打开小米手机的设置 点击我的设备 点击全部参数 点击多次点击MIUI版本即可将手机调整为开发者模式 返回设置页面,点击 ...
- 扇贝python离线_扇贝自动打卡Python脚本(Python3)
扇贝登录,不需要处理验证码,这一点使得该脚本简单许多 import requests import random import json 模拟浏览器,扇贝新闻PC端和移动端的阅读模式不同 header ...
最新文章
- 【laravel7.x中文文档】Redis
- vue项目接口地址暴露_vue项目打包后可以配置接口地址的方法
- 画验证曲线_数学老师用“函数曲线”绘出美图 学生舍不得擦
- 实现基于darknet框架实现CTPN版本自然场景文字检测 与CNN+CTCOCR文字识别的ChineseOCR搭建
- 仓库货位卡标识牌_仓库货架能解决传统仓储的哪些问题?
- LeetCode31.下一个排列 JavaScript
- 转载:基于Redis实现分布式锁
- Markdown 编辑器 Editor.md 使用
- OBS 录制简单操作说明
- 1167_ARM CORTEX-M0了解
- 块存储,文件存储,对象存储
- 【微分方程数值解】常微分方程(一)欧拉方法和改进欧拉方法(附python算例,封装类)
- 抖音通过什么方式变现,抖音变现方式分别有什么
- 居然有人能把5G解释的这么清楚
- js.offsetParent属性
- P2P通信中的NAT/FW穿越
- 大数据系列 | 全国职业院校技能大赛大数据应用技术赛项笔记分享-离线抽取模块
- JavaScript基础——第三章,JavaScript操作DOM对象
- 【IoT开发工具箱 | 02】嵌入式Linux设备网速测试方法
- 玩转Nginx服务器,怎能不懂Nginx的配置和优化?
热门文章
- VC++的GDI+中,DrawImage方法的应用入门
- 【mysql】ACID靠什么保证的?
- 网站推广工具-批量网站推广管理软件下载
- 斐波那契数列(循环)
- 3.5 函数的极值与最大值和最小值
- Linux 下 输入账号 密码 显示 last login:Mon Apr 1 05:49:00 on tty1 但是跳转不进去系统?
- 自动打开搜狗搜索的前五个链接
- nexus2.5版本升级到nexus2.14(同时升级到nexus3.24版本)版本
- php实现等比例缩放图片
- word文件损坏打不开如何修复?文件丢失怎么办?