文件结构调整

This commit is contained in:
MasonLiu 2025-01-02 17:11:11 +08:00
parent e594ca1711
commit 99651b2ff7
35 changed files with 131 additions and 147 deletions

View File

@ -34,7 +34,7 @@ from loguru import logger
# 清除所有已有的日志记录器配置 # 清除所有已有的日志记录器配置
logger.remove() logger.remove()
logger.add("./log/core.log", logger.add("./resources/log/core.log",
format="{time:YYYY-MM-DD HH:mm:ss} - {level} - {name}:{function}:{line} - {message}", format="{time:YYYY-MM-DD HH:mm:ss} - {level} - {name}:{function}:{line} - {message}",
rotation="100 MB", rotation="100 MB",
compression="zip", compression="zip",

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" """
@Author: MasonLiu @Author: MasonLiu
@Description: 本程序可以爬取各安全资讯源并发送到飞书群组 @Description: 测试用脚本无需关注
""" """
import schedule import schedule
@ -14,11 +14,11 @@ import requests
from datetime import datetime, timedelta from datetime import datetime, timedelta
from SendCore.FeishuSendBot import SendToFeishu, gen_sign from SendCore.FeishuSendBot import SendToFeishu, gen_sign
from SendCore.QiweiSendBot import SendToWX from SendCore.QiweiSendBot import SendToWX
from media.common import run, seebug_main, M_4hou_main, anquanke_main, sec_wiki_main, huawei_main, doonsec_main, qianxin_main from spider.common import run, seebug_main, M_4hou_main, anquanke_main, sec_wiki_main, huawei_main, doonsec_main, qianxin_main
from media.freebuf import freebuf_main from spider.freebuf import freebuf_main
from media.xianzhi import xianzhi_main from spider.xianzhi import xianzhi_main
from media.sougou_wx import sougou_wx_main from spider.sougou_wx import sougou_wx_main
from media.github import github_main from spider.github import github_main
from GotoSend.M_4hou import Src_4hou from GotoSend.M_4hou import Src_4hou
from GotoSend.anquanke import Src_anquanke from GotoSend.anquanke import Src_anquanke
from GotoSend.doonsec import Src_doonsec from GotoSend.doonsec import Src_doonsec
@ -27,28 +27,11 @@ from GotoSend.freebuf import Src_freebuf
from GotoSend.qianxin import Src_qianxin from GotoSend.qianxin import Src_qianxin
from GotoSend.seebug import Src_seebug from GotoSend.seebug import Src_seebug
from GotoSend.sougou_wx import Src_sougou_wx from GotoSend.sougou_wx import Src_sougou_wx
# from GotoSend.github import Src_github from GotoSend.github import Src_github
from config.check_config import get_core_config, get_debug_config, get_kewords_config from config.check_config import get_core_config, get_debug_config, get_kewords_config
from loguru import logger from loguru import logger
# # 全局变量
# webhook_url_once, timestamp_once, sign_once = gen_sign()
# e_hour, time_choice, choice, fs_activate, wx_activate, ding_activate, lx_activate, url_web = get_core_config()
# Sogou_WX = get_kewords_config()
# webhook_url, timestamp, sign = gen_sign()
# sougou_wx_main(Sogou_WX)
# result_sx_long = Src_sougou_wx(False)
# result_sx_short = Src_sougou_wx(True)
# webhook_url, timestamp, sign = gen_sign()
# SendToFeishu(result_sx_long, "微信公众号关键词相关内容", webhook_url, timestamp, sign)
github_main()
# # 测试用消息体 if __name__ == "__main__":
# test_msg = { logger.info("程序正在运行当中。")
# "请单件文档查看昨天讨论的方案相关飞书文档,注意作者为 <font color=red> **张三** <font> 版本为 \n*002* ,版本 ~~001~~ 已经删除。文件地址是 [https://www.feishu.cn](https://www.feishu.cn),打开次数:1次"
# }
# SendToFeishu(test_msg, "先知社区资讯递送", webhook_url, timestamp, sign)

View File

@ -6,7 +6,7 @@ import os
from datetime import datetime, timedelta from datetime import datetime, timedelta
def create_database(): def create_database():
conn = sqlite3.connect('./db/4hou.db') conn = sqlite3.connect('./resources/db/4hou.db')
cursor = conn.cursor() cursor = conn.cursor()
cursor.execute('''CREATE TABLE IF NOT EXISTS articles ( cursor.execute('''CREATE TABLE IF NOT EXISTS articles (
id INTEGER PRIMARY KEY AUTOINCREMENT, id INTEGER PRIMARY KEY AUTOINCREMENT,
@ -20,7 +20,7 @@ def create_database():
conn.close() conn.close()
def insert_data(data): def insert_data(data):
conn = sqlite3.connect('./db/4hou.db') conn = sqlite3.connect('./resources/db/4hou.db')
cursor = conn.cursor() cursor = conn.cursor()
for entry in data: for entry in data:
try: try:
@ -41,11 +41,11 @@ def insert_data(data):
def get_4hou_json(): def get_4hou_json():
# 检查文件是否存在 # 检查文件是否存在
if not os.path.exists('./JSON/4hou.json'): if not os.path.exists('./resources/JSON/4hou.json'):
raise FileNotFoundError(f"4hou.json文件不存在请检查程序是否运行正常") raise FileNotFoundError(f"4hou.json文件不存在请检查程序是否运行正常")
# 打开并读取JSON文件 # 打开并读取JSON文件
with open('./JSON/4hou.json', 'r', encoding='utf-8') as file: with open('./resources/JSON/4hou.json', 'r', encoding='utf-8') as file:
data = json.load(file) data = json.load(file)
# 假设data是一个包含多个JSON对象的列表 # 假设data是一个包含多个JSON对象的列表
@ -68,7 +68,7 @@ def get_4hou_json():
return total_data return total_data
def select_articles(e_hour): def select_articles(e_hour):
conn = sqlite3.connect('./db/4hou.db') conn = sqlite3.connect('./resources/db/4hou.db')
cursor = conn.cursor() cursor = conn.cursor()
# 获取当前日期和时间 # 获取当前日期和时间
@ -87,13 +87,13 @@ def select_articles(e_hour):
return results return results
def clear_table(): def clear_table():
conn = sqlite3.connect('./db/4hou.db') conn = sqlite3.connect('./resources/db/4hou.db')
cursor = conn.cursor() cursor = conn.cursor()
cursor.execute('DELETE FROM articles') cursor.execute('DELETE FROM articles')
conn.commit() conn.commit()
conn.close() conn.close()
def record_md(result, filename="./history/sec_news.md"): def record_md(result, filename="./resources/history/sec_news.md"):
# 读取现有内容 # 读取现有内容
if os.path.exists(filename): if os.path.exists(filename):
with open(filename, 'r', encoding='utf-8') as file: with open(filename, 'r', encoding='utf-8') as file:
@ -129,7 +129,7 @@ def get_filtered_articles(entries, Is_short):
def Src_4hou(e_hour, Is_short): def Src_4hou(e_hour, Is_short):
if not os.path.exists('./db/4hou.db'): if not os.path.exists('./resources/db/4hou.db'):
# 创建数据库和表 # 创建数据库和表
create_database() create_database()

View File

@ -7,7 +7,7 @@ from datetime import datetime, timedelta
def create_database(): def create_database():
conn = sqlite3.connect('./db/anquanke.db') conn = sqlite3.connect('./resources/db/anquanke.db')
cursor = conn.cursor() cursor = conn.cursor()
cursor.execute('''CREATE TABLE IF NOT EXISTS articles ( cursor.execute('''CREATE TABLE IF NOT EXISTS articles (
id INTEGER PRIMARY KEY AUTOINCREMENT, id INTEGER PRIMARY KEY AUTOINCREMENT,
@ -22,7 +22,7 @@ def create_database():
conn.close() conn.close()
def insert_data(data): def insert_data(data):
conn = sqlite3.connect('./db/anquanke.db') conn = sqlite3.connect('./resources/db/anquanke.db')
cursor = conn.cursor() cursor = conn.cursor()
for entry in data: for entry in data:
cursor.execute(''' cursor.execute('''
@ -34,11 +34,11 @@ def insert_data(data):
def get_anquanke_json(): def get_anquanke_json():
# 检查文件是否存在 # 检查文件是否存在
if not os.path.exists('./JSON/anquanke.json'): if not os.path.exists('./resources/JSON/anquanke.json'):
raise FileNotFoundError(f"anquanke.json文件不存在请检查程序是否运行正常") raise FileNotFoundError(f"anquanke.json文件不存在请检查程序是否运行正常")
# 打开并读取JSON文件 # 打开并读取JSON文件
with open('./JSON/anquanke.json', 'r', encoding='utf-8') as file: with open('./resources/JSON/anquanke.json', 'r', encoding='utf-8') as file:
data = json.load(file) data = json.load(file)
# 假设data是一个包含多个JSON对象的列表 # 假设data是一个包含多个JSON对象的列表
@ -62,7 +62,7 @@ def get_anquanke_json():
return total_data return total_data
def select_articles(e_hour): def select_articles(e_hour):
conn = sqlite3.connect('./db/anquanke.db') conn = sqlite3.connect('./resources/db/anquanke.db')
cursor = conn.cursor() cursor = conn.cursor()
# 获取当前日期和时间 # 获取当前日期和时间
@ -81,13 +81,13 @@ def select_articles(e_hour):
return results return results
def clear_table(): def clear_table():
conn = sqlite3.connect('./db/anquanke.db') conn = sqlite3.connect('./resources/db/anquanke.db')
cursor = conn.cursor() cursor = conn.cursor()
cursor.execute('DELETE FROM articles') cursor.execute('DELETE FROM articles')
conn.commit() conn.commit()
conn.close() conn.close()
def record_md(result, filename="./history/sec_news.md"): def record_md(result, filename="./resources/history/sec_news.md"):
# 读取现有内容 # 读取现有内容
if os.path.exists(filename): if os.path.exists(filename):
with open(filename, 'r', encoding='utf-8') as file: with open(filename, 'r', encoding='utf-8') as file:
@ -125,7 +125,7 @@ def get_filtered_articles(entries, Is_short):
def Src_anquanke(e_hour, Is_short): def Src_anquanke(e_hour, Is_short):
if not os.path.exists('./db/anquanke.db'): if not os.path.exists('./resources/db/anquanke.db'):
# 创建数据库和表 # 创建数据库和表
create_database() create_database()

View File

@ -7,7 +7,7 @@ from datetime import datetime, timedelta
def create_database(): def create_database():
conn = sqlite3.connect('./db/doonsec.db') conn = sqlite3.connect('./resources/db/doonsec.db')
cursor = conn.cursor() cursor = conn.cursor()
cursor.execute('''CREATE TABLE IF NOT EXISTS articles ( cursor.execute('''CREATE TABLE IF NOT EXISTS articles (
id INTEGER PRIMARY KEY AUTOINCREMENT, id INTEGER PRIMARY KEY AUTOINCREMENT,
@ -21,7 +21,7 @@ def create_database():
conn.close() conn.close()
def insert_data(data): def insert_data(data):
conn = sqlite3.connect('./db/doonsec.db') conn = sqlite3.connect('./resources/db/doonsec.db')
cursor = conn.cursor() cursor = conn.cursor()
for entry in data: for entry in data:
try: try:
@ -42,11 +42,11 @@ def insert_data(data):
def get_doonsec_json(): def get_doonsec_json():
# 检查文件是否存在 # 检查文件是否存在
if not os.path.exists('./JSON/doonsec.json'): if not os.path.exists('./resources/JSON/doonsec.json'):
raise FileNotFoundError(f"doonsec.json文件不存在请检查程序是否运行正常") raise FileNotFoundError(f"doonsec.json文件不存在请检查程序是否运行正常")
# 打开并读取JSON文件 # 打开并读取JSON文件
with open('./JSON/doonsec.json', 'r', encoding='utf-8') as file: with open('./resources/JSON/doonsec.json', 'r', encoding='utf-8') as file:
data = json.load(file) data = json.load(file)
# 假设data是一个包含多个JSON对象的列表 # 假设data是一个包含多个JSON对象的列表
@ -69,7 +69,7 @@ def get_doonsec_json():
return total_data return total_data
def select_articles(e_hour, Doonsec_switch, Doonsec): def select_articles(e_hour, Doonsec_switch, Doonsec):
conn = sqlite3.connect('./db/doonsec.db') conn = sqlite3.connect('./resources/db/doonsec.db')
cursor = conn.cursor() cursor = conn.cursor()
# 获取当前日期和时间 # 获取当前日期和时间
@ -105,13 +105,13 @@ def select_articles(e_hour, Doonsec_switch, Doonsec):
return results return results
def clear_table(): def clear_table():
conn = sqlite3.connect('./db/doonsec.db') conn = sqlite3.connect('./resources/db/doonsec.db')
cursor = conn.cursor() cursor = conn.cursor()
cursor.execute('DELETE FROM articles') cursor.execute('DELETE FROM articles')
conn.commit() conn.commit()
conn.close() conn.close()
def record_md(result, filename="./history/tech_passage.md"): def record_md(result, filename="./resources/history/tech_passage.md"):
# 读取现有内容 # 读取现有内容
if os.path.exists(filename): if os.path.exists(filename):
with open(filename, 'r', encoding='utf-8') as file: with open(filename, 'r', encoding='utf-8') as file:
@ -151,7 +151,7 @@ def get_filtered_articles(entries, Is_short):
def Src_doonsec(e_hour, Is_short, Doonsec_switch, Doonsec): def Src_doonsec(e_hour, Is_short, Doonsec_switch, Doonsec):
if not os.path.exists('./db/doonsec.db'): if not os.path.exists('./resources/db/doonsec.db'):
# 创建数据库和表 # 创建数据库和表
create_database() create_database()

View File

@ -6,7 +6,7 @@ import os
from datetime import datetime, timedelta from datetime import datetime, timedelta
def create_database(): def create_database():
conn = sqlite3.connect('./db/freebuf.db') conn = sqlite3.connect('./resources/db/freebuf.db')
cursor = conn.cursor() cursor = conn.cursor()
cursor.execute('''CREATE TABLE IF NOT EXISTS articles ( cursor.execute('''CREATE TABLE IF NOT EXISTS articles (
id INTEGER PRIMARY KEY AUTOINCREMENT, id INTEGER PRIMARY KEY AUTOINCREMENT,
@ -20,7 +20,7 @@ def create_database():
conn.close() conn.close()
def insert_data(data): def insert_data(data):
conn = sqlite3.connect('./db/freebuf.db') conn = sqlite3.connect('./resources/db/freebuf.db')
cursor = conn.cursor() cursor = conn.cursor()
for entry in data: for entry in data:
try: try:
@ -41,11 +41,11 @@ def insert_data(data):
def get_freebuf_json(): def get_freebuf_json():
# 检查文件是否存在 # 检查文件是否存在
if not os.path.exists('./JSON/freebuf.json'): if not os.path.exists('./resources/JSON/freebuf.json'):
raise FileNotFoundError(f"freebuf.json文件不存在请检查程序是否运行正常") raise FileNotFoundError(f"freebuf.json文件不存在请检查程序是否运行正常")
# 打开并读取JSON文件 # 打开并读取JSON文件
with open('./JSON/freebuf.json', 'r', encoding='utf-8') as file: with open('./resources/JSON/freebuf.json', 'r', encoding='utf-8') as file:
data = json.load(file) data = json.load(file)
# 假设data是一个包含多个JSON对象的列表 # 假设data是一个包含多个JSON对象的列表
@ -68,7 +68,7 @@ def get_freebuf_json():
return total_data return total_data
def select_articles(e_hour): def select_articles(e_hour):
conn = sqlite3.connect('./db/freebuf.db') conn = sqlite3.connect('./resources/db/freebuf.db')
cursor = conn.cursor() cursor = conn.cursor()
# 获取当前日期和时间 # 获取当前日期和时间
@ -87,13 +87,13 @@ def select_articles(e_hour):
return results return results
def clear_table(): def clear_table():
conn = sqlite3.connect('./db/freebuf.db') conn = sqlite3.connect('./resources/db/freebuf.db')
cursor = conn.cursor() cursor = conn.cursor()
cursor.execute('DELETE FROM articles') cursor.execute('DELETE FROM articles')
conn.commit() conn.commit()
conn.close() conn.close()
def record_md(result, filename="./history/sec_news.md"): def record_md(result, filename="./resources/history/sec_news.md"):
# 读取现有内容 # 读取现有内容
if os.path.exists(filename): if os.path.exists(filename):
with open(filename, 'r', encoding='utf-8') as file: with open(filename, 'r', encoding='utf-8') as file:
@ -130,7 +130,7 @@ def get_filtered_articles(entries, Is_short):
def Src_freebuf(e_hour, Is_short): def Src_freebuf(e_hour, Is_short):
if not os.path.exists('./db/freebuf.db'): if not os.path.exists('./resources/db/freebuf.db'):
# 创建数据库和表 # 创建数据库和表
create_database() create_database()

View File

@ -6,7 +6,7 @@ import os
from datetime import datetime, timedelta from datetime import datetime, timedelta
def create_database(): def create_database():
conn = sqlite3.connect('./db/github.db') conn = sqlite3.connect('./resources/db/github.db')
cursor = conn.cursor() cursor = conn.cursor()
cursor.executescript(''' cursor.executescript('''
@ -59,35 +59,35 @@ def insert_data():
# 检查文件是否存在 # 检查文件是否存在
# 打开并读取JSON文件 # 打开并读取JSON文件
# 假设data是一个包含多个JSON对象的列表然后校验JSON格式是否异常 # 假设data是一个包含多个JSON对象的列表然后校验JSON格式是否异常
if not os.path.exists('./JSON/github_keyword.json'): if not os.path.exists('./resources/JSON/github_keyword.json'):
raise FileNotFoundError(f"github_keyword文件不存在请检查程序是否运行正常") raise FileNotFoundError(f"github_keyword文件不存在请检查程序是否运行正常")
with open('./JSON/github_keyword.json', 'r', encoding='utf-8') as file: with open('./resources/JSON/github_keyword.json', 'r', encoding='utf-8') as file:
data_keyword = json.load(file) data_keyword = json.load(file)
if not isinstance(data_keyword, list): if not isinstance(data_keyword, list):
raise ValueError("JSON文件格式错误请检查爬取程序是否异常") raise ValueError("JSON文件格式错误请检查爬取程序是否异常")
if not os.path.exists('./JSON/github_repo.json'): if not os.path.exists('./resources/JSON/github_repo.json'):
raise FileNotFoundError(f"github_repo文件不存在请检查程序是否运行正常") raise FileNotFoundError(f"github_repo文件不存在请检查程序是否运行正常")
with open('./JSON/github_repo.json', 'r', encoding='utf-8') as file: with open('./resources/JSON/github_repo.json', 'r', encoding='utf-8') as file:
data_repo = json.load(file) data_repo = json.load(file)
if not isinstance(data_repo, list): if not isinstance(data_repo, list):
raise ValueError("JSON文件格式错误请检查爬取程序是否异常") raise ValueError("JSON文件格式错误请检查爬取程序是否异常")
if not os.path.exists('./JSON/github_release.json'): if not os.path.exists('./resources/JSON/github_release.json'):
raise FileNotFoundError(f"github_release文件不存在请检查程序是否运行正常") raise FileNotFoundError(f"github_release文件不存在请检查程序是否运行正常")
with open('./JSON/github_release.json', 'r', encoding='utf-8') as file: with open('./resources/JSON/github_release.json', 'r', encoding='utf-8') as file:
data_release = json.load(file) data_release = json.load(file)
if not isinstance(data_release, list): if not isinstance(data_release, list):
raise ValueError("JSON文件格式错误请检查爬取程序是否异常") raise ValueError("JSON文件格式错误请检查爬取程序是否异常")
if not os.path.exists('./JSON/github_user.json'): if not os.path.exists('./resources/JSON/github_user.json'):
raise FileNotFoundError(f"github_user文件不存在请检查程序是否运行正常") raise FileNotFoundError(f"github_user文件不存在请检查程序是否运行正常")
with open('./JSON/github_user.json', 'r', encoding='utf-8') as file: with open('./resources/JSON/github_user.json', 'r', encoding='utf-8') as file:
data_user = json.load(file) data_user = json.load(file)
if not isinstance(data_user, list): if not isinstance(data_user, list):
raise ValueError("JSON文件格式错误请检查爬取程序是否异常") raise ValueError("JSON文件格式错误请检查爬取程序是否异常")
conn = sqlite3.connect('./db/github.db') conn = sqlite3.connect('./resources/db/github.db')
cursor = conn.cursor() cursor = conn.cursor()
# 提取所需字段并编号 # 提取所需字段并编号
@ -209,7 +209,7 @@ def insert_data():
conn.close() conn.close()
def select_articles(e_hour): def select_articles(e_hour):
conn = sqlite3.connect('./db/github.db') conn = sqlite3.connect('./resources/db/github.db')
cursor = conn.cursor() cursor = conn.cursor()
# 获取当前日期和时间 # 获取当前日期和时间
@ -279,14 +279,14 @@ def select_articles(e_hour):
return result_1, result_2, result_3, result_4 return result_1, result_2, result_3, result_4
def clear_table(): def clear_table():
conn = sqlite3.connect('./db/github.db') conn = sqlite3.connect('./resources/db/github.db')
cursor = conn.cursor() cursor = conn.cursor()
cursor.execute('DELETE FROM repos') cursor.execute('DELETE FROM repos')
cursor.execute('DELETE FROM releases') cursor.execute('DELETE FROM releases')
conn.commit() conn.commit()
conn.close() conn.close()
def record_md(result, filename="./history/github.md"): def record_md(result, filename="./resources/history/github.md"):
# 读取现有内容 # 读取现有内容
if os.path.exists(filename): if os.path.exists(filename):
with open(filename, 'r', encoding='utf-8') as file: with open(filename, 'r', encoding='utf-8') as file:
@ -376,7 +376,7 @@ def get_filtered_articles(entries, Is_short, choice):
def Src_github(e_hour, Is_short): def Src_github(e_hour, Is_short):
if not os.path.exists('./db/github.db'): if not os.path.exists('./resources/db/github.db'):
# 创建数据库和表 # 创建数据库和表
create_database() create_database()

View File

@ -6,7 +6,7 @@ import os
from datetime import datetime, timedelta from datetime import datetime, timedelta
def create_database(): def create_database():
conn = sqlite3.connect('./db/qianxin.db') conn = sqlite3.connect('./resources/db/qianxin.db')
cursor = conn.cursor() cursor = conn.cursor()
cursor.execute('''CREATE TABLE IF NOT EXISTS articles ( cursor.execute('''CREATE TABLE IF NOT EXISTS articles (
id INTEGER PRIMARY KEY AUTOINCREMENT, id INTEGER PRIMARY KEY AUTOINCREMENT,
@ -20,7 +20,7 @@ def create_database():
conn.close() conn.close()
def insert_data(data): def insert_data(data):
conn = sqlite3.connect('./db/qianxin.db') conn = sqlite3.connect('./resources/db/qianxin.db')
cursor = conn.cursor() cursor = conn.cursor()
for entry in data: for entry in data:
cursor.execute(''' cursor.execute('''
@ -32,11 +32,11 @@ def insert_data(data):
def get_qianxin_json(): def get_qianxin_json():
# 检查文件是否存在 # 检查文件是否存在
if not os.path.exists('./JSON/qianxin.json'): if not os.path.exists('./resources/JSON/qianxin.json'):
raise FileNotFoundError(f"qianxin.json文件不存在请检查程序是否运行正常") raise FileNotFoundError(f"qianxin.json文件不存在请检查程序是否运行正常")
# 打开并读取JSON文件 # 打开并读取JSON文件
with open('./JSON/qianxin.json', 'r', encoding='utf-8') as file: with open('./resources/JSON/qianxin.json', 'r', encoding='utf-8') as file:
data = json.load(file) data = json.load(file)
# 假设data是一个包含多个JSON对象的列表 # 假设data是一个包含多个JSON对象的列表
@ -59,7 +59,7 @@ def get_qianxin_json():
return total_data return total_data
def select_articles(e_hour): def select_articles(e_hour):
conn = sqlite3.connect('./db/qianxin.db') conn = sqlite3.connect('./resources/db/qianxin.db')
cursor = conn.cursor() cursor = conn.cursor()
# 获取当前日期和时间 # 获取当前日期和时间
@ -78,13 +78,13 @@ def select_articles(e_hour):
return results return results
def clear_table(): def clear_table():
conn = sqlite3.connect('./db/qianxin.db') conn = sqlite3.connect('./resources/db/qianxin.db')
cursor = conn.cursor() cursor = conn.cursor()
cursor.execute('DELETE FROM articles') cursor.execute('DELETE FROM articles')
conn.commit() conn.commit()
conn.close() conn.close()
def record_md(result, filename="./history/tech_passage.md"): def record_md(result, filename="./resources/history/tech_passage.md"):
# 读取现有内容 # 读取现有内容
if os.path.exists(filename): if os.path.exists(filename):
with open(filename, 'r', encoding='utf-8') as file: with open(filename, 'r', encoding='utf-8') as file:
@ -123,7 +123,7 @@ def get_filtered_articles(entries, Is_short):
def Src_qianxin(e_hour, Is_short): def Src_qianxin(e_hour, Is_short):
if not os.path.exists('./db/qianxin.db'): if not os.path.exists('./resources/db/qianxin.db'):
# 创建数据库和表 # 创建数据库和表
create_database() create_database()

View File

@ -8,7 +8,7 @@ import email.utils
def create_database(): def create_database():
conn = sqlite3.connect('./db/seebug.db') conn = sqlite3.connect('./resources/db/seebug.db')
cursor = conn.cursor() cursor = conn.cursor()
cursor.execute('''CREATE TABLE IF NOT EXISTS articles ( cursor.execute('''CREATE TABLE IF NOT EXISTS articles (
id INTEGER PRIMARY KEY AUTOINCREMENT, id INTEGER PRIMARY KEY AUTOINCREMENT,
@ -23,7 +23,7 @@ def create_database():
def insert_data(data): def insert_data(data):
conn = sqlite3.connect('./db/seebug.db') conn = sqlite3.connect('./resources/db/seebug.db')
cursor = conn.cursor() cursor = conn.cursor()
for entry in data: for entry in data:
# 解析并格式化时间 # 解析并格式化时间
@ -39,11 +39,11 @@ def insert_data(data):
def get_seebug_json(): def get_seebug_json():
# 检查文件是否存在 # 检查文件是否存在
if not os.path.exists('./JSON/seebug.json'): if not os.path.exists('./resources/JSON/seebug.json'):
raise FileNotFoundError(f"seebug.json文件不存在请检查程序是否运行正常") raise FileNotFoundError(f"seebug.json文件不存在请检查程序是否运行正常")
# 打开并读取JSON文件 # 打开并读取JSON文件
with open('./JSON/seebug.json', 'r', encoding='utf-8') as file: with open('./resources/JSON/seebug.json', 'r', encoding='utf-8') as file:
data = json.load(file) data = json.load(file)
# 假设data是一个包含多个JSON对象的列表 # 假设data是一个包含多个JSON对象的列表
@ -66,7 +66,7 @@ def get_seebug_json():
return total_data return total_data
def select_articles(e_hour): def select_articles(e_hour):
conn = sqlite3.connect('./db/seebug.db') conn = sqlite3.connect('./resources/db/seebug.db')
cursor = conn.cursor() cursor = conn.cursor()
# 获取当前日期和时间 # 获取当前日期和时间
@ -85,13 +85,13 @@ def select_articles(e_hour):
return results return results
def clear_table(): def clear_table():
conn = sqlite3.connect('./db/seebug.db') conn = sqlite3.connect('./resources/db/seebug.db')
cursor = conn.cursor() cursor = conn.cursor()
cursor.execute('DELETE FROM articles') cursor.execute('DELETE FROM articles')
conn.commit() conn.commit()
conn.close() conn.close()
def record_md(result, filename="./history/sec_news.md"): def record_md(result, filename="./resources/history/sec_news.md"):
# 读取现有内容 # 读取现有内容
if os.path.exists(filename): if os.path.exists(filename):
with open(filename, 'r', encoding='utf-8') as file: with open(filename, 'r', encoding='utf-8') as file:
@ -130,7 +130,7 @@ def get_filtered_articles(entries, Is_short):
def Src_seebug(e_hour, Is_short): def Src_seebug(e_hour, Is_short):
if not os.path.exists('./db/seebug.db'): if not os.path.exists('./resources/db/seebug.db'):
# 创建数据库和表 # 创建数据库和表
create_database() create_database()

View File

@ -4,14 +4,14 @@ import sqlite3
from datetime import datetime, timedelta from datetime import datetime, timedelta
def clear_table(): def clear_table():
conn = sqlite3.connect('./db/sougou-wx.db') conn = sqlite3.connect('./resources/db/sougou-wx.db')
cursor = conn.cursor() cursor = conn.cursor()
cursor.execute('DELETE FROM articles') cursor.execute('DELETE FROM articles')
conn.commit() conn.commit()
conn.close() conn.close()
def create_database(): def create_database():
conn = sqlite3.connect('./db/sougou-wx.db') conn = sqlite3.connect('./resources/db/sougou-wx.db')
cursor = conn.cursor() cursor = conn.cursor()
cursor.execute('''CREATE TABLE IF NOT EXISTS articles ( cursor.execute('''CREATE TABLE IF NOT EXISTS articles (
id INTEGER PRIMARY KEY AUTOINCREMENT, id INTEGER PRIMARY KEY AUTOINCREMENT,
@ -27,7 +27,7 @@ def create_database():
conn.close() conn.close()
def insert_data(data): def insert_data(data):
conn = sqlite3.connect('./db/sougou-wx.db') conn = sqlite3.connect('./resources/db/sougou-wx.db')
cursor = conn.cursor() cursor = conn.cursor()
for entry in data: for entry in data:
# 检查是否存在相同 title 和 author 的记录 # 检查是否存在相同 title 和 author 的记录
@ -47,11 +47,11 @@ def insert_data(data):
def get_json(): def get_json():
# 检查文件是否存在 # 检查文件是否存在
if not os.path.exists('./JSON/sougou-wx.json'): if not os.path.exists('./resources/JSON/sougou-wx.json'):
raise FileNotFoundError(f"sougou-wx.json文件不存在请检查程序是否运行正常") raise FileNotFoundError(f"sougou-wx.json文件不存在请检查程序是否运行正常")
# 打开并读取JSON文件 # 打开并读取JSON文件
with open('./JSON/sougou-wx.json', 'r', encoding='utf-8') as file: with open('./resources/JSON/sougou-wx.json', 'r', encoding='utf-8') as file:
data = json.load(file) data = json.load(file)
# 假设data是一个包含多个关键词的字典 # 假设data是一个包含多个关键词的字典
@ -77,7 +77,7 @@ def get_json():
return total_data return total_data
def select_articles(): def select_articles():
conn = sqlite3.connect('./db/sougou-wx.db') conn = sqlite3.connect('./resources/db/sougou-wx.db')
cursor = conn.cursor() cursor = conn.cursor()
# 获取当前日期和时间 # 获取当前日期和时间
@ -124,7 +124,7 @@ def select_articles():
return results return results
def record_md(result, filename="./history/wx_news.md"): def record_md(result, filename="./resources/history/wx_news.md"):
# 读取现有内容 # 读取现有内容
if os.path.exists(filename): if os.path.exists(filename):
with open(filename, 'r', encoding='utf-8') as file: with open(filename, 'r', encoding='utf-8') as file:
@ -163,7 +163,7 @@ def get_filtered_articles(entries, Is_short):
return result return result
def Src_sougou_wx(Is_short): def Src_sougou_wx(Is_short):
if not os.path.exists('./db/sougou-wx.db'): if not os.path.exists('./resources/db/sougou-wx.db'):
# 创建数据库和表 # 创建数据库和表
create_database() create_database()

View File

@ -6,7 +6,7 @@ import os
from datetime import datetime, timedelta from datetime import datetime, timedelta
def create_database(): def create_database():
conn = sqlite3.connect('./db/xianzhi.db') conn = sqlite3.connect('./resources/db/xianzhi.db')
cursor = conn.cursor() cursor = conn.cursor()
cursor.execute('''CREATE TABLE IF NOT EXISTS articles ( cursor.execute('''CREATE TABLE IF NOT EXISTS articles (
id INTEGER PRIMARY KEY AUTOINCREMENT, id INTEGER PRIMARY KEY AUTOINCREMENT,
@ -18,7 +18,7 @@ def create_database():
conn.close() conn.close()
def insert_data(data): def insert_data(data):
conn = sqlite3.connect('./db/xianzhi.db') conn = sqlite3.connect('./resources/db/xianzhi.db')
cursor = conn.cursor() cursor = conn.cursor()
for entry in data: for entry in data:
try: try:
@ -40,11 +40,11 @@ def insert_data(data):
def get_xianzhi_json(): def get_xianzhi_json():
# 检查文件是否存在 # 检查文件是否存在
if not os.path.exists('./JSON/xianzhi.json'): if not os.path.exists('./resources/JSON/xianzhi.json'):
raise FileNotFoundError(f"xianzhi.json文件不存在请检查程序是否运行正常") raise FileNotFoundError(f"xianzhi.json文件不存在请检查程序是否运行正常")
# 打开并读取JSON文件 # 打开并读取JSON文件
with open('./JSON/xianzhi.json', 'r', encoding='utf-8') as file: with open('./resources/JSON/xianzhi.json', 'r', encoding='utf-8') as file:
data = json.load(file) data = json.load(file)
# 假设data是一个包含多个JSON对象的列表 # 假设data是一个包含多个JSON对象的列表
@ -65,7 +65,7 @@ def get_xianzhi_json():
return total_data return total_data
def select_articles(e_hour): def select_articles(e_hour):
conn = sqlite3.connect('./db/xianzhi.db') conn = sqlite3.connect('./resources/db/xianzhi.db')
cursor = conn.cursor() cursor = conn.cursor()
# 获取当前日期和时间 # 获取当前日期和时间
@ -84,13 +84,13 @@ def select_articles(e_hour):
return results return results
def clear_table(): def clear_table():
conn = sqlite3.connect('./db/xianzhi.db') conn = sqlite3.connect('./resources/db/xianzhi.db')
cursor = conn.cursor() cursor = conn.cursor()
cursor.execute('DELETE FROM articles') cursor.execute('DELETE FROM articles')
conn.commit() conn.commit()
conn.close() conn.close()
def record_md(result, filename="./history/tech_passage.md"): def record_md(result, filename="./resources/history/tech_passage.md"):
# 读取现有内容 # 读取现有内容
if os.path.exists(filename): if os.path.exists(filename):
with open(filename, 'r', encoding='utf-8') as file: with open(filename, 'r', encoding='utf-8') as file:
@ -126,7 +126,7 @@ def get_filtered_articles(entries, Is_short):
def Src_xianzhi(e_hour, Is_short): def Src_xianzhi(e_hour, Is_short):
if not os.path.exists('./db/xianzhi.db'): if not os.path.exists('./resources/db/xianzhi.db'):
# 创建数据库和表 # 创建数据库和表
create_database() create_database()

View File

@ -29,4 +29,5 @@
- 2024年12月25日晚优化了推送报文格式 <br> - 2024年12月25日晚优化了推送报文格式 <br>
- 2024年12月30日添加并完善了基于搜狗搜索的微信公众号文章监测 <br> - 2024年12月30日添加并完善了基于搜狗搜索的微信公众号文章监测 <br>
- 2024年12月30日晚为洞见微信资讯推送添加了关键词筛选 <br> - 2024年12月30日晚为洞见微信资讯推送添加了关键词筛选 <br>
- 2025年01月02日更新并上线了Github项目监测功能readme后续更新中 <br> - 2025年01月02日更新并上线了Github项目监测功能readme后续更新中 <br>
- 2025年01月02日晚再次优化了文件结构提高可读性 <br>

View File

Before

Width:  |  Height:  |  Size: 267 KiB

After

Width:  |  Height:  |  Size: 267 KiB

View File

Before

Width:  |  Height:  |  Size: 113 KiB

After

Width:  |  Height:  |  Size: 113 KiB

View File

Before

Width:  |  Height:  |  Size: 109 KiB

After

Width:  |  Height:  |  Size: 109 KiB

View File

Before

Width:  |  Height:  |  Size: 211 KiB

After

Width:  |  Height:  |  Size: 211 KiB

View File

Before

Width:  |  Height:  |  Size: 275 KiB

After

Width:  |  Height:  |  Size: 275 KiB

View File

Before

Width:  |  Height:  |  Size: 199 KiB

After

Width:  |  Height:  |  Size: 199 KiB

View File

Before

Width:  |  Height:  |  Size: 117 KiB

After

Width:  |  Height:  |  Size: 117 KiB

View File

Before

Width:  |  Height:  |  Size: 95 KiB

After

Width:  |  Height:  |  Size: 95 KiB

View File

@ -73,11 +73,11 @@ def seebug_main():
items = parse_rss(rss_content) items = parse_rss(rss_content)
# 确保目录存在 # 确保目录存在
os.makedirs(os.path.dirname('./JSON/seebug.json'), exist_ok=True) os.makedirs(os.path.dirname('./resources/JSON/seebug.json'), exist_ok=True)
# 将解析后的数据保存到 JSON 文件 # 将解析后的数据保存到 JSON 文件
save_to_json(items, './JSON/seebug.json') save_to_json(items, './resources/JSON/seebug.json')
logger.info("数据已保存到 ./JSON/seebug.json") logger.info("数据已保存到 ./resources/JSON/seebug.json")
# 4hou 爬虫 # 4hou 爬虫
def M_4hou_main(): def M_4hou_main():
@ -91,11 +91,11 @@ def M_4hou_main():
items = parse_rss(rss_content) items = parse_rss(rss_content)
# 确保目录存在 # 确保目录存在
os.makedirs(os.path.dirname('./JSON/4hou.json'), exist_ok=True) os.makedirs(os.path.dirname('./resources/JSON/4hou.json'), exist_ok=True)
# 将解析后的数据保存到 JSON 文件 # 将解析后的数据保存到 JSON 文件
save_to_json(items, './JSON/4hou.json') save_to_json(items, './resources/JSON/4hou.json')
logger.info("数据已保存到 ./JSON/4hou.json") logger.info("数据已保存到 ./resources/JSON/4hou.json")
# 安全客 爬虫 # 安全客 爬虫
def anquanke_main(): def anquanke_main():
@ -109,11 +109,11 @@ def anquanke_main():
items = parse_rss(rss_content) items = parse_rss(rss_content)
# 确保目录存在 # 确保目录存在
os.makedirs(os.path.dirname('./JSON/anquanke.json'), exist_ok=True) os.makedirs(os.path.dirname('./resources/JSON/anquanke.json'), exist_ok=True)
# 将解析后的数据保存到 JSON 文件 # 将解析后的数据保存到 JSON 文件
save_to_json(items, './JSON/anquanke.json') save_to_json(items, './resources/JSON/anquanke.json')
logger.info("数据已保存到 ./JSON/anquanke.json") logger.info("数据已保存到 ./resources/JSON/anquanke.json")
# sec_wiki 爬虫 # sec_wiki 爬虫
def sec_wiki_main(): def sec_wiki_main():
@ -127,11 +127,11 @@ def sec_wiki_main():
items = parse_rss(rss_content) items = parse_rss(rss_content)
# 确保目录存在 # 确保目录存在
os.makedirs(os.path.dirname('./JSON/sec_wiki.json'), exist_ok=True) os.makedirs(os.path.dirname('./resources/JSON/sec_wiki.json'), exist_ok=True)
# 将解析后的数据保存到 JSON 文件 # 将解析后的数据保存到 JSON 文件
save_to_json(items, './JSON/sec_wiki.json') save_to_json(items, './resources/JSON/sec_wiki.json')
logger.info("数据已保存到 ./JSON/sec_wiki.json") logger.info("数据已保存到 ./resources/JSON/sec_wiki.json")
# 华为 爬虫 # 华为 爬虫
def huawei_main(): def huawei_main():
@ -145,11 +145,11 @@ def huawei_main():
items = parse_rss(rss_content) items = parse_rss(rss_content)
# 确保目录存在 # 确保目录存在
os.makedirs(os.path.dirname('./JSON/huawei.json'), exist_ok=True) os.makedirs(os.path.dirname('./resources/JSON/huawei.json'), exist_ok=True)
# 将解析后的数据保存到 JSON 文件 # 将解析后的数据保存到 JSON 文件
save_to_json(items, './JSON/huawei.json') save_to_json(items, './resources/JSON/huawei.json')
logger.info("数据已保存到 ./JSON/huawei.json") logger.info("数据已保存到 ./resources/JSON/huawei.json")
# 洞见微信聚合爬虫 # 洞见微信聚合爬虫
def doonsec_main(): def doonsec_main():
@ -163,11 +163,11 @@ def doonsec_main():
items = parse_rss(rss_content) items = parse_rss(rss_content)
# 确保目录存在 # 确保目录存在
os.makedirs(os.path.dirname('./JSON/doonsec.json'), exist_ok=True) os.makedirs(os.path.dirname('./resources/JSON/doonsec.json'), exist_ok=True)
# 将解析后的数据保存到 JSON 文件 # 将解析后的数据保存到 JSON 文件
save_to_json(items, './JSON/doonsec.json') save_to_json(items, './resources/JSON/doonsec.json')
logger.info("数据已保存到 ./JSON/doonsec.json") logger.info("数据已保存到 ./resources/JSON/doonsec.json")
# 奇安信攻防社区 爬虫 # 奇安信攻防社区 爬虫
def qianxin_main(): def qianxin_main():
@ -181,11 +181,11 @@ def qianxin_main():
items = parse_rss(rss_content) items = parse_rss(rss_content)
# 确保目录存在 # 确保目录存在
os.makedirs(os.path.dirname('./JSON/qianxin.json'), exist_ok=True) os.makedirs(os.path.dirname('./resources/JSON/qianxin.json'), exist_ok=True)
# 将解析后的数据保存到 JSON 文件 # 将解析后的数据保存到 JSON 文件
save_to_json(items, './JSON/qianxin.json') save_to_json(items, './resources/JSON/qianxin.json')
logger.info("数据已保存到 ./JSON/qianxin.json") logger.info("数据已保存到 ./resources/JSON/qianxin.json")
def run(): def run():
seebug_main() seebug_main()

View File

@ -62,11 +62,11 @@ def freebuf_main():
items = parse_rss(rss_content) items = parse_rss(rss_content)
# 确保目录存在 # 确保目录存在
os.makedirs(os.path.dirname('./JSON/freebuf.json'), exist_ok=True) os.makedirs(os.path.dirname('./resources/JSON/freebuf.json'), exist_ok=True)
# 将解析后的数据保存到 JSON 文件 # 将解析后的数据保存到 JSON 文件
save_to_json(items, './JSON/freebuf.json') save_to_json(items, './resources/JSON/freebuf.json')
logger.info("数据已保存到 ./JSON/freebuf.json") logger.info("数据已保存到 ./resources/JSON/freebuf.json")
except Exception as e: except Exception as e:
logger.error(f"解析或保存Freebuf RSS内容时发生错误: {e}") logger.error(f"解析或保存Freebuf RSS内容时发生错误: {e}")

View File

@ -85,7 +85,7 @@ def github_main_keyword(key):
time.sleep(5) time.sleep(5)
# 将所有结果写入JSON文件 # 将所有结果写入JSON文件
save_to_json(all_results, './JSON/github_keyword.json') save_to_json(all_results, './resources/JSON/github_keyword.json')
def github_main_repo(key): def github_main_repo(key):
@ -128,7 +128,7 @@ def github_main_repo(key):
time.sleep(5) time.sleep(5)
# 将所有结果写入JSON文件 # 将所有结果写入JSON文件
save_to_json(all_results, './JSON/github_repo.json') save_to_json(all_results, './resources/JSON/github_repo.json')
def github_main_release(key): def github_main_release(key):
all_results = [] # 用于存储所有结果 all_results = [] # 用于存储所有结果
@ -160,7 +160,7 @@ def github_main_release(key):
time.sleep(5) time.sleep(5)
# 将所有结果写入JSON文件 # 将所有结果写入JSON文件
save_to_json(all_results, './JSON/github_release.json') save_to_json(all_results, './resources/JSON/github_release.json')
def github_main_user(key): def github_main_user(key):
all_results = [] # 用于存储所有结果 all_results = [] # 用于存储所有结果
@ -207,7 +207,7 @@ def github_main_user(key):
time.sleep(5) time.sleep(5)
# 将所有结果写入JSON文件 # 将所有结果写入JSON文件
save_to_json(all_results, './JSON/github_user.json') save_to_json(all_results, './resources/JSON/github_user.json')
def github_main(): def github_main():
if keyword_list: if keyword_list:

View File

@ -108,10 +108,10 @@ def sougou_wx_main(keywords):
# print(json_results) # print(json_results)
# 确保目录存在 # 确保目录存在
os.makedirs(os.path.dirname('./JSON/sougou-wx.json'), exist_ok=True) os.makedirs(os.path.dirname('./resources/JSON/sougou-wx.json'), exist_ok=True)
# 将解析后的数据保存到 JSON 文件 # 将解析后的数据保存到 JSON 文件
with open('./JSON/sougou-wx.json', 'w', encoding='utf-8') as f: with open('./resources/JSON/sougou-wx.json', 'w', encoding='utf-8') as f:
f.write(json_results) f.write(json_results)
if __name__ == "__main__": if __name__ == "__main__":

View File

@ -61,10 +61,10 @@ def xianzhi_main():
json_data = json.dumps(entries_json, ensure_ascii=False, indent=4) json_data = json.dumps(entries_json, ensure_ascii=False, indent=4)
# 保存 JSON 数据到文件 # 保存 JSON 数据到文件
with open('./JSON/xianzhi.json', 'w', encoding='utf-8') as json_file: with open('./resources/JSON/xianzhi.json', 'w', encoding='utf-8') as json_file:
json_file.write(json_data) json_file.write(json_data)
logger.info("数据已保存到 ./JSON/xianzhi.json") logger.info("数据已保存到 ./resources/JSON/xianzhi.json")
except Exception as e: except Exception as e:
logger.error(f"解析或保存先知社区RSS内容时发生错误: {e}") logger.error(f"解析或保存先知社区RSS内容时发生错误: {e}")

View File

@ -7,10 +7,10 @@ app = Flask(__name__)
# 配置文件路径 # 配置文件路径
BASE_DIR = os.path.dirname(os.path.abspath(__file__)) BASE_DIR = os.path.dirname(os.path.abspath(__file__))
PARENT_DIR = os.path.dirname(BASE_DIR) # 上一个文件夹 PARENT_DIR = os.path.dirname(BASE_DIR) # 上一个文件夹
SEC_NEWS_PATH = os.path.join(PARENT_DIR, 'history', 'sec_news.md') SEC_NEWS_PATH = os.path.join(PARENT_DIR, 'resources', 'history', 'sec_news.md')
TECH_PASSAGE_PATH = os.path.join(PARENT_DIR, 'history', 'tech_passage.md') TECH_PASSAGE_PATH = os.path.join(PARENT_DIR, 'resources', 'history', 'tech_passage.md')
CORE_LOG_PATH = os.path.join(PARENT_DIR, 'log', 'core.log') CORE_LOG_PATH = os.path.join(PARENT_DIR, 'resources', 'log', 'core.log')
WEB_LOG_PATH = os.path.join(PARENT_DIR, 'log', 'app.log') WEB_LOG_PATH = os.path.join(PARENT_DIR, 'resources', 'log', 'app.log')
# 配置日志记录器 # 配置日志记录器
logging.basicConfig( logging.basicConfig(

View File

@ -5,20 +5,20 @@
config.yaml: 配置各模块参数以及Token密钥 config.yaml: 配置各模块参数以及Token密钥
check_config.py: 核查配置信息并获取到配置信息返回给核心程序 check_config.py: 核查配置信息并获取到配置信息返回给核心程序
- ./log - ./resources/log
app.py: web运行日志 app.py: web运行日志
core.py: 程序运行日志 core.py: 程序运行日志
- ./media - ./media
爬取RSS源以及信息源的json数据并保存 爬取RSS源以及信息源的json数据并保存
- ./JSON - ./resources/JSON
存储获取到的原始json数据 存储获取到的原始json数据
- ./GotoSend - ./GotoSend
对获取到的json数据进行处理将其存储值db文件内 对获取到的json数据进行处理将其存储值db文件内
- ./db - ./resources/db
存储处理过后的数据 存储处理过后的数据
- ./SendCore - ./SendCore
@ -27,8 +27,8 @@ FeishuSendBot.py: 飞书推送核心程序
MailSendBot.py: 邮件推送核心程序 MailSendBot.py: 邮件推送核心程序
QiweiSendBot.py: 企业微信推送核心程序 QiweiSendBot.py: 企业微信推送核心程序
- ./history - ./resources/history
存储历史推送记录为markdown文件 存储历史推送记录为markdown文件
- ./Web - ./web
网页运行程序 网页运行程序