70 lines
1.8 KiB
Python
70 lines
1.8 KiB
Python
import asyncio
|
|
|
|
import toml
|
|
|
|
from PT.pt_operation import PtOperation
|
|
|
|
'''
|
|
new Env('PT自动签到和开注检测');
|
|
0 0 15 * * ?
|
|
'''
|
|
toml_file = 'PT/pt_config.toml'
|
|
|
|
|
|
async def attendances():
|
|
"""
|
|
签到
|
|
:return:
|
|
"""
|
|
pt_opt = PtOperation()
|
|
try:
|
|
with open(toml_file, 'r', encoding='utf-8') as file:
|
|
config_data = toml.load(file)
|
|
# 迭代每个 section
|
|
for section_name, section_data in config_data.items():
|
|
url, cookie, flag = section_data.get('url'), section_data.get('cookie'), section_data.get('flag')
|
|
if flag != 1 and cookie is not None and len(cookie.strip()) > 0:
|
|
print(f"Processing section: {section_name} --- {section_data.get('url')}")
|
|
# 签到
|
|
await pt_opt.attendances(section_data)
|
|
except FileNotFoundError:
|
|
print(f"Error: The file '{toml_file}' was not found.")
|
|
except toml.TomlDecodeError as e:
|
|
print(f"Error decoding TOML: {e}")
|
|
|
|
|
|
async def signup():
|
|
"""
|
|
开注提醒
|
|
:return:
|
|
"""
|
|
pt_opt = PtOperation()
|
|
try:
|
|
with open(toml_file, 'r', encoding='utf-8') as file:
|
|
config_data = toml.load(file)
|
|
# 迭代每个 section
|
|
for section_name, section_data in config_data.items():
|
|
url, cookie, flag = section_data.get('url'), section_data.get('cookie'), section_data.get('flag')
|
|
if flag != 1:
|
|
print(f"Processing section: {section_name} --- {section_data.get('url')}")
|
|
# 开注提醒
|
|
await pt_opt.signup(section_data)
|
|
except FileNotFoundError:
|
|
print(f"Error: The file '{toml_file}' was not found.")
|
|
except toml.TomlDecodeError as e:
|
|
print(f"Error decoding TOML: {e}")
|
|
|
|
|
|
# 拉取网站数据
|
|
# 做种
|
|
|
|
|
|
if __name__ == '__main__':
|
|
# PtOperation().opt()
|
|
loop = asyncio.get_event_loop()
|
|
# 使用 asyncio.gather 可以运行多个异步任务
|
|
results = loop.run_until_complete(asyncio.gather(
|
|
attendances(), signup()
|
|
))
|
|
# print(results)
|