Skip to content

Commit

Permalink
计划任务
Browse files Browse the repository at this point in the history
计划任务
  • Loading branch information
tianzhengs committed Nov 12, 2022
1 parent d18ca59 commit 845d275
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 5 deletions.
27 changes: 25 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os
import time

import sys
from study import study


Expand Down Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
13 changes: 12 additions & 1 deletion runtest.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
# Created by STZ at 11/12/2022
print('ASDFLKJH')
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()

0 comments on commit 845d275

Please sign in to comment.