文件结构调整
2
Core.py
@ -34,7 +34,7 @@ from loguru import logger
|
||||
# 清除所有已有的日志记录器配置
|
||||
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}",
|
||||
rotation="100 MB",
|
||||
compression="zip",
|
||||
|
35
Dev_test.py
@ -1,7 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
@Author: MasonLiu
|
||||
@Description: 本程序可以爬取各安全资讯源,并发送到飞书群组。
|
||||
@Description: 测试用脚本,无需关注。
|
||||
"""
|
||||
|
||||
import schedule
|
||||
@ -14,11 +14,11 @@ import requests
|
||||
from datetime import datetime, timedelta
|
||||
from SendCore.FeishuSendBot import SendToFeishu, gen_sign
|
||||
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 media.freebuf import freebuf_main
|
||||
from media.xianzhi import xianzhi_main
|
||||
from media.sougou_wx import sougou_wx_main
|
||||
from media.github import github_main
|
||||
from spider.common import run, seebug_main, M_4hou_main, anquanke_main, sec_wiki_main, huawei_main, doonsec_main, qianxin_main
|
||||
from spider.freebuf import freebuf_main
|
||||
from spider.xianzhi import xianzhi_main
|
||||
from spider.sougou_wx import sougou_wx_main
|
||||
from spider.github import github_main
|
||||
from GotoSend.M_4hou import Src_4hou
|
||||
from GotoSend.anquanke import Src_anquanke
|
||||
from GotoSend.doonsec import Src_doonsec
|
||||
@ -27,28 +27,11 @@ from GotoSend.freebuf import Src_freebuf
|
||||
from GotoSend.qianxin import Src_qianxin
|
||||
from GotoSend.seebug import Src_seebug
|
||||
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 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()
|
||||
|
||||
|
||||
# # 测试用消息体
|
||||
# test_msg = {
|
||||
# "请单件文档查看昨天讨论的方案相关飞书文档,注意作者为 <font color=red> **张三** <font> 版本为 \n*002* ,版本 ~~001~~ 已经删除。文件地址是 [https://www.feishu.cn](https://www.feishu.cn),打开次数:1次"
|
||||
# }
|
||||
|
||||
# SendToFeishu(test_msg, "先知社区资讯递送", webhook_url, timestamp, sign)
|
||||
if __name__ == "__main__":
|
||||
logger.info("程序正在运行当中。")
|
@ -6,7 +6,7 @@ import os
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
def create_database():
|
||||
conn = sqlite3.connect('./db/4hou.db')
|
||||
conn = sqlite3.connect('./resources/db/4hou.db')
|
||||
cursor = conn.cursor()
|
||||
cursor.execute('''CREATE TABLE IF NOT EXISTS articles (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
@ -20,7 +20,7 @@ def create_database():
|
||||
conn.close()
|
||||
|
||||
def insert_data(data):
|
||||
conn = sqlite3.connect('./db/4hou.db')
|
||||
conn = sqlite3.connect('./resources/db/4hou.db')
|
||||
cursor = conn.cursor()
|
||||
for entry in data:
|
||||
try:
|
||||
@ -41,11 +41,11 @@ def insert_data(data):
|
||||
|
||||
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文件不存在,请检查程序是否运行正常!")
|
||||
|
||||
# 打开并读取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对象的列表
|
||||
@ -68,7 +68,7 @@ def get_4hou_json():
|
||||
return total_data
|
||||
|
||||
def select_articles(e_hour):
|
||||
conn = sqlite3.connect('./db/4hou.db')
|
||||
conn = sqlite3.connect('./resources/db/4hou.db')
|
||||
cursor = conn.cursor()
|
||||
|
||||
# 获取当前日期和时间
|
||||
@ -87,13 +87,13 @@ def select_articles(e_hour):
|
||||
return results
|
||||
|
||||
def clear_table():
|
||||
conn = sqlite3.connect('./db/4hou.db')
|
||||
conn = sqlite3.connect('./resources/db/4hou.db')
|
||||
cursor = conn.cursor()
|
||||
cursor.execute('DELETE FROM articles')
|
||||
conn.commit()
|
||||
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):
|
||||
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):
|
||||
if not os.path.exists('./db/4hou.db'):
|
||||
if not os.path.exists('./resources/db/4hou.db'):
|
||||
# 创建数据库和表
|
||||
create_database()
|
||||
|
||||
|
@ -7,7 +7,7 @@ from datetime import datetime, timedelta
|
||||
|
||||
|
||||
def create_database():
|
||||
conn = sqlite3.connect('./db/anquanke.db')
|
||||
conn = sqlite3.connect('./resources/db/anquanke.db')
|
||||
cursor = conn.cursor()
|
||||
cursor.execute('''CREATE TABLE IF NOT EXISTS articles (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
@ -22,7 +22,7 @@ def create_database():
|
||||
conn.close()
|
||||
|
||||
def insert_data(data):
|
||||
conn = sqlite3.connect('./db/anquanke.db')
|
||||
conn = sqlite3.connect('./resources/db/anquanke.db')
|
||||
cursor = conn.cursor()
|
||||
for entry in data:
|
||||
cursor.execute('''
|
||||
@ -34,11 +34,11 @@ def insert_data(data):
|
||||
|
||||
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文件不存在,请检查程序是否运行正常!")
|
||||
|
||||
# 打开并读取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对象的列表
|
||||
@ -62,7 +62,7 @@ def get_anquanke_json():
|
||||
return total_data
|
||||
|
||||
def select_articles(e_hour):
|
||||
conn = sqlite3.connect('./db/anquanke.db')
|
||||
conn = sqlite3.connect('./resources/db/anquanke.db')
|
||||
cursor = conn.cursor()
|
||||
|
||||
# 获取当前日期和时间
|
||||
@ -81,13 +81,13 @@ def select_articles(e_hour):
|
||||
return results
|
||||
|
||||
def clear_table():
|
||||
conn = sqlite3.connect('./db/anquanke.db')
|
||||
conn = sqlite3.connect('./resources/db/anquanke.db')
|
||||
cursor = conn.cursor()
|
||||
cursor.execute('DELETE FROM articles')
|
||||
conn.commit()
|
||||
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):
|
||||
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):
|
||||
if not os.path.exists('./db/anquanke.db'):
|
||||
if not os.path.exists('./resources/db/anquanke.db'):
|
||||
# 创建数据库和表
|
||||
create_database()
|
||||
|
||||
|
@ -7,7 +7,7 @@ from datetime import datetime, timedelta
|
||||
|
||||
|
||||
def create_database():
|
||||
conn = sqlite3.connect('./db/doonsec.db')
|
||||
conn = sqlite3.connect('./resources/db/doonsec.db')
|
||||
cursor = conn.cursor()
|
||||
cursor.execute('''CREATE TABLE IF NOT EXISTS articles (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
@ -21,7 +21,7 @@ def create_database():
|
||||
conn.close()
|
||||
|
||||
def insert_data(data):
|
||||
conn = sqlite3.connect('./db/doonsec.db')
|
||||
conn = sqlite3.connect('./resources/db/doonsec.db')
|
||||
cursor = conn.cursor()
|
||||
for entry in data:
|
||||
try:
|
||||
@ -42,11 +42,11 @@ def insert_data(data):
|
||||
|
||||
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文件不存在,请检查程序是否运行正常!")
|
||||
|
||||
# 打开并读取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对象的列表
|
||||
@ -69,7 +69,7 @@ def get_doonsec_json():
|
||||
return total_data
|
||||
|
||||
def select_articles(e_hour, Doonsec_switch, Doonsec):
|
||||
conn = sqlite3.connect('./db/doonsec.db')
|
||||
conn = sqlite3.connect('./resources/db/doonsec.db')
|
||||
cursor = conn.cursor()
|
||||
|
||||
# 获取当前日期和时间
|
||||
@ -105,13 +105,13 @@ def select_articles(e_hour, Doonsec_switch, Doonsec):
|
||||
return results
|
||||
|
||||
def clear_table():
|
||||
conn = sqlite3.connect('./db/doonsec.db')
|
||||
conn = sqlite3.connect('./resources/db/doonsec.db')
|
||||
cursor = conn.cursor()
|
||||
cursor.execute('DELETE FROM articles')
|
||||
conn.commit()
|
||||
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):
|
||||
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):
|
||||
if not os.path.exists('./db/doonsec.db'):
|
||||
if not os.path.exists('./resources/db/doonsec.db'):
|
||||
# 创建数据库和表
|
||||
create_database()
|
||||
|
||||
|
@ -6,7 +6,7 @@ import os
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
def create_database():
|
||||
conn = sqlite3.connect('./db/freebuf.db')
|
||||
conn = sqlite3.connect('./resources/db/freebuf.db')
|
||||
cursor = conn.cursor()
|
||||
cursor.execute('''CREATE TABLE IF NOT EXISTS articles (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
@ -20,7 +20,7 @@ def create_database():
|
||||
conn.close()
|
||||
|
||||
def insert_data(data):
|
||||
conn = sqlite3.connect('./db/freebuf.db')
|
||||
conn = sqlite3.connect('./resources/db/freebuf.db')
|
||||
cursor = conn.cursor()
|
||||
for entry in data:
|
||||
try:
|
||||
@ -41,11 +41,11 @@ def insert_data(data):
|
||||
|
||||
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文件不存在,请检查程序是否运行正常!")
|
||||
|
||||
# 打开并读取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对象的列表
|
||||
@ -68,7 +68,7 @@ def get_freebuf_json():
|
||||
return total_data
|
||||
|
||||
def select_articles(e_hour):
|
||||
conn = sqlite3.connect('./db/freebuf.db')
|
||||
conn = sqlite3.connect('./resources/db/freebuf.db')
|
||||
cursor = conn.cursor()
|
||||
|
||||
# 获取当前日期和时间
|
||||
@ -87,13 +87,13 @@ def select_articles(e_hour):
|
||||
return results
|
||||
|
||||
def clear_table():
|
||||
conn = sqlite3.connect('./db/freebuf.db')
|
||||
conn = sqlite3.connect('./resources/db/freebuf.db')
|
||||
cursor = conn.cursor()
|
||||
cursor.execute('DELETE FROM articles')
|
||||
conn.commit()
|
||||
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):
|
||||
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):
|
||||
if not os.path.exists('./db/freebuf.db'):
|
||||
if not os.path.exists('./resources/db/freebuf.db'):
|
||||
# 创建数据库和表
|
||||
create_database()
|
||||
|
||||
|
@ -6,7 +6,7 @@ import os
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
def create_database():
|
||||
conn = sqlite3.connect('./db/github.db')
|
||||
conn = sqlite3.connect('./resources/db/github.db')
|
||||
cursor = conn.cursor()
|
||||
|
||||
cursor.executescript('''
|
||||
@ -59,35 +59,35 @@ def insert_data():
|
||||
# 检查文件是否存在
|
||||
# 打开并读取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文件不存在,请检查程序是否运行正常!")
|
||||
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)
|
||||
if not isinstance(data_keyword, list):
|
||||
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文件不存在,请检查程序是否运行正常!")
|
||||
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)
|
||||
if not isinstance(data_repo, list):
|
||||
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文件不存在,请检查程序是否运行正常!")
|
||||
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)
|
||||
if not isinstance(data_release, list):
|
||||
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文件不存在,请检查程序是否运行正常!")
|
||||
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)
|
||||
if not isinstance(data_user, list):
|
||||
raise ValueError("JSON文件格式错误,请检查爬取程序是否异常!")
|
||||
|
||||
conn = sqlite3.connect('./db/github.db')
|
||||
conn = sqlite3.connect('./resources/db/github.db')
|
||||
cursor = conn.cursor()
|
||||
|
||||
# 提取所需字段并编号
|
||||
@ -209,7 +209,7 @@ def insert_data():
|
||||
conn.close()
|
||||
|
||||
def select_articles(e_hour):
|
||||
conn = sqlite3.connect('./db/github.db')
|
||||
conn = sqlite3.connect('./resources/db/github.db')
|
||||
cursor = conn.cursor()
|
||||
|
||||
# 获取当前日期和时间
|
||||
@ -279,14 +279,14 @@ def select_articles(e_hour):
|
||||
return result_1, result_2, result_3, result_4
|
||||
|
||||
def clear_table():
|
||||
conn = sqlite3.connect('./db/github.db')
|
||||
conn = sqlite3.connect('./resources/db/github.db')
|
||||
cursor = conn.cursor()
|
||||
cursor.execute('DELETE FROM repos')
|
||||
cursor.execute('DELETE FROM releases')
|
||||
conn.commit()
|
||||
conn.close()
|
||||
|
||||
def record_md(result, filename="./history/github.md"):
|
||||
def record_md(result, filename="./resources/history/github.md"):
|
||||
# 读取现有内容
|
||||
if os.path.exists(filename):
|
||||
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):
|
||||
if not os.path.exists('./db/github.db'):
|
||||
if not os.path.exists('./resources/db/github.db'):
|
||||
# 创建数据库和表
|
||||
create_database()
|
||||
|
||||
|
@ -6,7 +6,7 @@ import os
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
def create_database():
|
||||
conn = sqlite3.connect('./db/qianxin.db')
|
||||
conn = sqlite3.connect('./resources/db/qianxin.db')
|
||||
cursor = conn.cursor()
|
||||
cursor.execute('''CREATE TABLE IF NOT EXISTS articles (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
@ -20,7 +20,7 @@ def create_database():
|
||||
conn.close()
|
||||
|
||||
def insert_data(data):
|
||||
conn = sqlite3.connect('./db/qianxin.db')
|
||||
conn = sqlite3.connect('./resources/db/qianxin.db')
|
||||
cursor = conn.cursor()
|
||||
for entry in data:
|
||||
cursor.execute('''
|
||||
@ -32,11 +32,11 @@ def insert_data(data):
|
||||
|
||||
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文件不存在,请检查程序是否运行正常!")
|
||||
|
||||
# 打开并读取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对象的列表
|
||||
@ -59,7 +59,7 @@ def get_qianxin_json():
|
||||
return total_data
|
||||
|
||||
def select_articles(e_hour):
|
||||
conn = sqlite3.connect('./db/qianxin.db')
|
||||
conn = sqlite3.connect('./resources/db/qianxin.db')
|
||||
cursor = conn.cursor()
|
||||
|
||||
# 获取当前日期和时间
|
||||
@ -78,13 +78,13 @@ def select_articles(e_hour):
|
||||
return results
|
||||
|
||||
def clear_table():
|
||||
conn = sqlite3.connect('./db/qianxin.db')
|
||||
conn = sqlite3.connect('./resources/db/qianxin.db')
|
||||
cursor = conn.cursor()
|
||||
cursor.execute('DELETE FROM articles')
|
||||
conn.commit()
|
||||
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):
|
||||
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):
|
||||
if not os.path.exists('./db/qianxin.db'):
|
||||
if not os.path.exists('./resources/db/qianxin.db'):
|
||||
# 创建数据库和表
|
||||
create_database()
|
||||
|
||||
|
@ -8,7 +8,7 @@ import email.utils
|
||||
|
||||
|
||||
def create_database():
|
||||
conn = sqlite3.connect('./db/seebug.db')
|
||||
conn = sqlite3.connect('./resources/db/seebug.db')
|
||||
cursor = conn.cursor()
|
||||
cursor.execute('''CREATE TABLE IF NOT EXISTS articles (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
@ -23,7 +23,7 @@ def create_database():
|
||||
|
||||
|
||||
def insert_data(data):
|
||||
conn = sqlite3.connect('./db/seebug.db')
|
||||
conn = sqlite3.connect('./resources/db/seebug.db')
|
||||
cursor = conn.cursor()
|
||||
for entry in data:
|
||||
# 解析并格式化时间
|
||||
@ -39,11 +39,11 @@ def insert_data(data):
|
||||
|
||||
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文件不存在,请检查程序是否运行正常!")
|
||||
|
||||
# 打开并读取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对象的列表
|
||||
@ -66,7 +66,7 @@ def get_seebug_json():
|
||||
return total_data
|
||||
|
||||
def select_articles(e_hour):
|
||||
conn = sqlite3.connect('./db/seebug.db')
|
||||
conn = sqlite3.connect('./resources/db/seebug.db')
|
||||
cursor = conn.cursor()
|
||||
|
||||
# 获取当前日期和时间
|
||||
@ -85,13 +85,13 @@ def select_articles(e_hour):
|
||||
return results
|
||||
|
||||
def clear_table():
|
||||
conn = sqlite3.connect('./db/seebug.db')
|
||||
conn = sqlite3.connect('./resources/db/seebug.db')
|
||||
cursor = conn.cursor()
|
||||
cursor.execute('DELETE FROM articles')
|
||||
conn.commit()
|
||||
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):
|
||||
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):
|
||||
if not os.path.exists('./db/seebug.db'):
|
||||
if not os.path.exists('./resources/db/seebug.db'):
|
||||
# 创建数据库和表
|
||||
create_database()
|
||||
|
||||
|
@ -4,14 +4,14 @@ import sqlite3
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
def clear_table():
|
||||
conn = sqlite3.connect('./db/sougou-wx.db')
|
||||
conn = sqlite3.connect('./resources/db/sougou-wx.db')
|
||||
cursor = conn.cursor()
|
||||
cursor.execute('DELETE FROM articles')
|
||||
conn.commit()
|
||||
conn.close()
|
||||
|
||||
def create_database():
|
||||
conn = sqlite3.connect('./db/sougou-wx.db')
|
||||
conn = sqlite3.connect('./resources/db/sougou-wx.db')
|
||||
cursor = conn.cursor()
|
||||
cursor.execute('''CREATE TABLE IF NOT EXISTS articles (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
@ -27,7 +27,7 @@ def create_database():
|
||||
conn.close()
|
||||
|
||||
def insert_data(data):
|
||||
conn = sqlite3.connect('./db/sougou-wx.db')
|
||||
conn = sqlite3.connect('./resources/db/sougou-wx.db')
|
||||
cursor = conn.cursor()
|
||||
for entry in data:
|
||||
# 检查是否存在相同 title 和 author 的记录
|
||||
@ -47,11 +47,11 @@ def insert_data(data):
|
||||
|
||||
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文件不存在,请检查程序是否运行正常!")
|
||||
|
||||
# 打开并读取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是一个包含多个关键词的字典
|
||||
@ -77,7 +77,7 @@ def get_json():
|
||||
return total_data
|
||||
|
||||
def select_articles():
|
||||
conn = sqlite3.connect('./db/sougou-wx.db')
|
||||
conn = sqlite3.connect('./resources/db/sougou-wx.db')
|
||||
cursor = conn.cursor()
|
||||
|
||||
# 获取当前日期和时间
|
||||
@ -124,7 +124,7 @@ def select_articles():
|
||||
|
||||
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):
|
||||
with open(filename, 'r', encoding='utf-8') as file:
|
||||
@ -163,7 +163,7 @@ def get_filtered_articles(entries, Is_short):
|
||||
return result
|
||||
|
||||
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()
|
||||
|
||||
|
@ -6,7 +6,7 @@ import os
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
def create_database():
|
||||
conn = sqlite3.connect('./db/xianzhi.db')
|
||||
conn = sqlite3.connect('./resources/db/xianzhi.db')
|
||||
cursor = conn.cursor()
|
||||
cursor.execute('''CREATE TABLE IF NOT EXISTS articles (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
@ -18,7 +18,7 @@ def create_database():
|
||||
conn.close()
|
||||
|
||||
def insert_data(data):
|
||||
conn = sqlite3.connect('./db/xianzhi.db')
|
||||
conn = sqlite3.connect('./resources/db/xianzhi.db')
|
||||
cursor = conn.cursor()
|
||||
for entry in data:
|
||||
try:
|
||||
@ -40,11 +40,11 @@ def insert_data(data):
|
||||
|
||||
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文件不存在,请检查程序是否运行正常!")
|
||||
|
||||
# 打开并读取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对象的列表
|
||||
@ -65,7 +65,7 @@ def get_xianzhi_json():
|
||||
return total_data
|
||||
|
||||
def select_articles(e_hour):
|
||||
conn = sqlite3.connect('./db/xianzhi.db')
|
||||
conn = sqlite3.connect('./resources/db/xianzhi.db')
|
||||
cursor = conn.cursor()
|
||||
|
||||
# 获取当前日期和时间
|
||||
@ -84,13 +84,13 @@ def select_articles(e_hour):
|
||||
return results
|
||||
|
||||
def clear_table():
|
||||
conn = sqlite3.connect('./db/xianzhi.db')
|
||||
conn = sqlite3.connect('./resources/db/xianzhi.db')
|
||||
cursor = conn.cursor()
|
||||
cursor.execute('DELETE FROM articles')
|
||||
conn.commit()
|
||||
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):
|
||||
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):
|
||||
if not os.path.exists('./db/xianzhi.db'):
|
||||
if not os.path.exists('./resources/db/xianzhi.db'):
|
||||
# 创建数据库和表
|
||||
create_database()
|
||||
|
||||
|
@ -29,4 +29,5 @@
|
||||
- 2024年12月25日晚:优化了推送报文格式 <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>
|
Before Width: | Height: | Size: 267 KiB After Width: | Height: | Size: 267 KiB |
Before Width: | Height: | Size: 113 KiB After Width: | Height: | Size: 113 KiB |
Before Width: | Height: | Size: 109 KiB After Width: | Height: | Size: 109 KiB |
Before Width: | Height: | Size: 211 KiB After Width: | Height: | Size: 211 KiB |
Before Width: | Height: | Size: 275 KiB After Width: | Height: | Size: 275 KiB |
Before Width: | Height: | Size: 199 KiB After Width: | Height: | Size: 199 KiB |
Before Width: | Height: | Size: 117 KiB After Width: | Height: | Size: 117 KiB |
Before Width: | Height: | Size: 95 KiB After Width: | Height: | Size: 95 KiB |
@ -73,11 +73,11 @@ def seebug_main():
|
||||
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 文件
|
||||
save_to_json(items, './JSON/seebug.json')
|
||||
logger.info("数据已保存到 ./JSON/seebug.json!")
|
||||
save_to_json(items, './resources/JSON/seebug.json')
|
||||
logger.info("数据已保存到 ./resources/JSON/seebug.json!")
|
||||
|
||||
# 4hou 爬虫
|
||||
def M_4hou_main():
|
||||
@ -91,11 +91,11 @@ def M_4hou_main():
|
||||
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 文件
|
||||
save_to_json(items, './JSON/4hou.json')
|
||||
logger.info("数据已保存到 ./JSON/4hou.json!")
|
||||
save_to_json(items, './resources/JSON/4hou.json')
|
||||
logger.info("数据已保存到 ./resources/JSON/4hou.json!")
|
||||
|
||||
# 安全客 爬虫
|
||||
def anquanke_main():
|
||||
@ -109,11 +109,11 @@ def anquanke_main():
|
||||
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 文件
|
||||
save_to_json(items, './JSON/anquanke.json')
|
||||
logger.info("数据已保存到 ./JSON/anquanke.json!")
|
||||
save_to_json(items, './resources/JSON/anquanke.json')
|
||||
logger.info("数据已保存到 ./resources/JSON/anquanke.json!")
|
||||
|
||||
# sec_wiki 爬虫
|
||||
def sec_wiki_main():
|
||||
@ -127,11 +127,11 @@ def sec_wiki_main():
|
||||
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 文件
|
||||
save_to_json(items, './JSON/sec_wiki.json')
|
||||
logger.info("数据已保存到 ./JSON/sec_wiki.json!")
|
||||
save_to_json(items, './resources/JSON/sec_wiki.json')
|
||||
logger.info("数据已保存到 ./resources/JSON/sec_wiki.json!")
|
||||
|
||||
# 华为 爬虫
|
||||
def huawei_main():
|
||||
@ -145,11 +145,11 @@ def huawei_main():
|
||||
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 文件
|
||||
save_to_json(items, './JSON/huawei.json')
|
||||
logger.info("数据已保存到 ./JSON/huawei.json!")
|
||||
save_to_json(items, './resources/JSON/huawei.json')
|
||||
logger.info("数据已保存到 ./resources/JSON/huawei.json!")
|
||||
|
||||
# 洞见微信聚合爬虫
|
||||
def doonsec_main():
|
||||
@ -163,11 +163,11 @@ def doonsec_main():
|
||||
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 文件
|
||||
save_to_json(items, './JSON/doonsec.json')
|
||||
logger.info("数据已保存到 ./JSON/doonsec.json!")
|
||||
save_to_json(items, './resources/JSON/doonsec.json')
|
||||
logger.info("数据已保存到 ./resources/JSON/doonsec.json!")
|
||||
|
||||
# 奇安信攻防社区 爬虫
|
||||
def qianxin_main():
|
||||
@ -181,11 +181,11 @@ def qianxin_main():
|
||||
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 文件
|
||||
save_to_json(items, './JSON/qianxin.json')
|
||||
logger.info("数据已保存到 ./JSON/qianxin.json!")
|
||||
save_to_json(items, './resources/JSON/qianxin.json')
|
||||
logger.info("数据已保存到 ./resources/JSON/qianxin.json!")
|
||||
|
||||
def run():
|
||||
seebug_main()
|
||||
|
@ -62,11 +62,11 @@ def freebuf_main():
|
||||
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 文件
|
||||
save_to_json(items, './JSON/freebuf.json')
|
||||
logger.info("数据已保存到 ./JSON/freebuf.json!")
|
||||
save_to_json(items, './resources/JSON/freebuf.json')
|
||||
logger.info("数据已保存到 ./resources/JSON/freebuf.json!")
|
||||
except Exception as e:
|
||||
logger.error(f"解析或保存Freebuf RSS内容时发生错误: {e}")
|
||||
|
||||
|
@ -85,7 +85,7 @@ def github_main_keyword(key):
|
||||
time.sleep(5)
|
||||
|
||||
# 将所有结果写入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):
|
||||
@ -128,7 +128,7 @@ def github_main_repo(key):
|
||||
time.sleep(5)
|
||||
|
||||
# 将所有结果写入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):
|
||||
all_results = [] # 用于存储所有结果
|
||||
@ -160,7 +160,7 @@ def github_main_release(key):
|
||||
time.sleep(5)
|
||||
|
||||
# 将所有结果写入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):
|
||||
all_results = [] # 用于存储所有结果
|
||||
@ -207,7 +207,7 @@ def github_main_user(key):
|
||||
time.sleep(5)
|
||||
|
||||
# 将所有结果写入JSON文件
|
||||
save_to_json(all_results, './JSON/github_user.json')
|
||||
save_to_json(all_results, './resources/JSON/github_user.json')
|
||||
|
||||
def github_main():
|
||||
if keyword_list:
|
||||
|
@ -108,10 +108,10 @@ def sougou_wx_main(keywords):
|
||||
# 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 文件
|
||||
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)
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
@ -61,10 +61,10 @@ def xianzhi_main():
|
||||
json_data = json.dumps(entries_json, ensure_ascii=False, indent=4)
|
||||
|
||||
# 保存 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)
|
||||
|
||||
logger.info("数据已保存到 ./JSON/xianzhi.json!")
|
||||
logger.info("数据已保存到 ./resources/JSON/xianzhi.json!")
|
||||
except Exception as e:
|
||||
logger.error(f"解析或保存先知社区RSS内容时发生错误: {e}")
|
||||
|
||||
|
@ -7,10 +7,10 @@ app = Flask(__name__)
|
||||
# 配置文件路径
|
||||
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
PARENT_DIR = os.path.dirname(BASE_DIR) # 上一个文件夹
|
||||
SEC_NEWS_PATH = os.path.join(PARENT_DIR, 'history', 'sec_news.md')
|
||||
TECH_PASSAGE_PATH = os.path.join(PARENT_DIR, 'history', 'tech_passage.md')
|
||||
CORE_LOG_PATH = os.path.join(PARENT_DIR, 'log', 'core.log')
|
||||
WEB_LOG_PATH = os.path.join(PARENT_DIR, 'log', 'app.log')
|
||||
SEC_NEWS_PATH = os.path.join(PARENT_DIR, 'resources', 'history', 'sec_news.md')
|
||||
TECH_PASSAGE_PATH = os.path.join(PARENT_DIR, 'resources', 'history', 'tech_passage.md')
|
||||
CORE_LOG_PATH = os.path.join(PARENT_DIR, 'resources', 'log', 'core.log')
|
||||
WEB_LOG_PATH = os.path.join(PARENT_DIR, 'resources', 'log', 'app.log')
|
||||
|
||||
# 配置日志记录器
|
||||
logging.basicConfig(
|
||||
|
10
功能解释.md
@ -5,20 +5,20 @@
|
||||
config.yaml: 配置各模块参数以及Token密钥
|
||||
check_config.py: 核查配置信息并获取到配置信息返回给核心程序
|
||||
|
||||
- ./log
|
||||
- ./resources/log
|
||||
app.py: web运行日志
|
||||
core.py: 程序运行日志
|
||||
|
||||
- ./media
|
||||
爬取RSS源以及信息源的json数据并保存
|
||||
|
||||
- ./JSON
|
||||
- ./resources/JSON
|
||||
存储获取到的原始json数据
|
||||
|
||||
- ./GotoSend
|
||||
对获取到的json数据进行处理,将其存储值db文件内
|
||||
|
||||
- ./db
|
||||
- ./resources/db
|
||||
存储处理过后的数据
|
||||
|
||||
- ./SendCore
|
||||
@ -27,8 +27,8 @@ FeishuSendBot.py: 飞书推送核心程序
|
||||
MailSendBot.py: 邮件推送核心程序
|
||||
QiweiSendBot.py: 企业微信推送核心程序
|
||||
|
||||
- ./history
|
||||
- ./resources/history
|
||||
存储历史推送记录为markdown文件
|
||||
|
||||
- ./Web
|
||||
- ./web
|
||||
网页运行程序
|