From 845d275f046b3c64791dcd6f6e4717b4c990858e Mon Sep 17 00:00:00 2001 From: Silen <64316216+startkkkkkk@users.noreply.github.com> Date: Sat, 12 Nov 2022 18:12:11 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A1=E5=88=92=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 计划任务 --- main.py | 27 +++++++++++++++++++++++++-- readme.md | 4 ++-- runtest.py | 13 ++++++++++++- 3 files changed, 39 insertions(+), 5 deletions(-) diff --git a/main.py b/main.py index 2b9438b..ccf08a0 100644 --- a/main.py +++ b/main.py @@ -1,6 +1,6 @@ import os import time - +import sys from study import study @@ -33,11 +33,34 @@ def getAccounts(): ua = os.getenv('UA', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36 Edg/106.0.1370.42') -accounts = getAccounts() + +# Windows Automated Task Management +task_name="Daxuexi_18S4F65D" +if os.name == 'nt': + if task_name in os.popen("SCHTASKS /query").read(): + print("脚本配置的计划任务已存在") + # + 检测路径 + else: + if 1: # change to 0 if you want to manage it yourself + input("没有脚本配置的计划任务,按任意键创建;或者退出并把main.py 43行的1改成0") + k=os.popen(f"{sys.executable} ./runtest.py").read() + if 'SHOULDBEFINE\n'!=k: + if 'FAILIMPORT\n'==k: + print("依赖问题") + else: + print('创建失败?Python位置不对?') + exit(1) + create=os.popen(f'''SchTasks /Create /SC DAILY /MO 2 /TN {task_name} /TR "'{sys.executable}' '{os.path.realpath(__file__)}'" /ST 09:00''') + print('创建成功') + +# accounts = getAccounts() +accounts=[('********', '*********')] print(f'账号数量:{len(accounts)}') successful = 0 count = 0 for username, password in accounts: + if username=='********': + continue count += 1 print(f'--User {count}--') if study(username, password, ua): diff --git a/readme.md b/readme.md index 5e7ae22..23cb027 100644 --- a/readme.md +++ b/readme.md @@ -17,11 +17,11 @@ GitHub IP被封啦,只能本地运行了 安装依赖: 在解压出来的目录里运行`pip install -r requirements.txt`或`pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple` (如果国内环境+没配置代理) -配置账号: main.py 36行 注释掉加一行或修改成 accounts=[('账号1', '密码1'),('账号2', '密码2'),('账号3', '密码3')] +配置账号: main.py 中 accounts = getAccounts() 一行改成 accounts=[('账号1', '密码1'),('账号2', '密码2'),('账号3', '密码3')]形式 运行: 运行`main.py` -自动运行:搜索“计划任务”相关,脚本更新后会自动配置2天一次的计划任务 +自动运行:可搜索“计划任务”相关,Windows下脚本会自动尝试配置2天一次的计划任务 # 本地运行 -Linux diff --git a/runtest.py b/runtest.py index 4581232..7c21080 100644 --- a/runtest.py +++ b/runtest.py @@ -1,2 +1,13 @@ # Created by STZ at 11/12/2022 -print('ASDFLKJH') \ No newline at end of file +try: + from Crypto.Cipher import PKCS1_v1_5 as Cipher_pksc1_v1_5 + from Crypto.PublicKey import RSA + from PIL import Image + import requests + from ddddocr import DdddOcr + import onnxruntime + import numpy as np + print('SHOULDBEFINE') +except: + print('FAILIMPORT') + exit()