2024-12-03 00:03:14 +08:00
|
|
|
import signal
|
|
|
|
from datetime import datetime
|
|
|
|
import sys
|
|
|
|
import time
|
2024-12-04 00:08:44 +08:00
|
|
|
import yaml
|
|
|
|
# from SendBot import SendToFeishu
|
2024-12-03 00:03:14 +08:00
|
|
|
from media.common import run
|
|
|
|
from media.freebuf import freebuf_main
|
|
|
|
from media.xianzhi import xianzhi_main
|
2024-12-04 00:08:44 +08:00
|
|
|
from GotoSend_4hou import Src_4hou
|
|
|
|
from GotoSend_anquanke import Src_anquanke
|
|
|
|
from GotoSend_doonsec import Src_doonsec
|
2024-12-03 00:03:14 +08:00
|
|
|
|
2024-12-04 00:08:44 +08:00
|
|
|
# 加载参数
|
|
|
|
def get_params():
|
|
|
|
with open('./config.yaml', 'r', encoding="utf-8") as file:
|
|
|
|
config = yaml.safe_load(file)
|
|
|
|
sleep_time = f"{config['sleep_time']}"
|
|
|
|
s_hour = int(f"{config['s_hour']}")
|
|
|
|
e_hour = int(f"{config['e_hour']}")
|
|
|
|
c_hour = int(f"{config['c_hour']}")
|
|
|
|
|
|
|
|
return sleep_time, s_hour, e_hour, c_hour
|
|
|
|
|
|
|
|
sleep_time, s_hour, e_hour, c_hour = get_params()
|
2024-12-03 00:03:14 +08:00
|
|
|
|
|
|
|
def crab_job():
|
|
|
|
print("正在启动各爬虫并获取资源中...")
|
|
|
|
run()
|
|
|
|
xianzhi_main()
|
|
|
|
freebuf_main()
|
|
|
|
|
2024-12-04 00:08:44 +08:00
|
|
|
def send_job():
|
|
|
|
Src_4hou(s_hour, e_hour)
|
|
|
|
Src_anquanke(s_hour, e_hour)
|
|
|
|
Src_doonsec(s_hour, e_hour)
|
|
|
|
|
2024-12-03 00:03:14 +08:00
|
|
|
def signal_handler(sig, frame):
|
|
|
|
print("接收到退出信号,程序即将退出...")
|
|
|
|
sys.exit(0)
|
|
|
|
|
|
|
|
|
|
|
|
signal.signal(signal.SIGINT, signal_handler) # Ctrl+C
|
|
|
|
signal.signal(signal.SIGTERM, signal_handler) # kill命令
|
|
|
|
|
|
|
|
def main_loop():
|
|
|
|
while True:
|
|
|
|
try:
|
|
|
|
# 获取当前时间
|
|
|
|
now = datetime.now()
|
|
|
|
# 检查是否为特定时间点
|
2024-12-04 00:08:44 +08:00
|
|
|
if now.hour == c_hour and now.minute == 5:
|
2024-12-03 00:03:14 +08:00
|
|
|
crab_job()
|
2024-12-04 00:08:44 +08:00
|
|
|
send_job()
|
2024-12-03 00:03:14 +08:00
|
|
|
print("执行完毕,等待下一次执行...")
|
|
|
|
else:
|
2024-12-04 00:08:44 +08:00
|
|
|
pass
|
|
|
|
# print("正在等待执行...")
|
|
|
|
# print("等待间隔:", int(sleep_time))
|
|
|
|
time.sleep(int(sleep_time)) # 每隔35秒执行一次
|
2024-12-03 00:03:14 +08:00
|
|
|
except Exception as e:
|
2024-12-03 17:33:37 +08:00
|
|
|
print(f"发生错误: {e} ,程序已暂停")
|
2024-12-04 00:08:44 +08:00
|
|
|
# SendToFeishu(f"发生错误: {e} ,程序已退出", "报错信息")
|
2024-12-03 00:03:14 +08:00
|
|
|
exit()
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2024-12-04 00:08:44 +08:00
|
|
|
print("程序正在运行当中。")
|
2024-12-03 00:03:14 +08:00
|
|
|
main_loop()
|