文件结构调整

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

No files matched your search

+8 -8
View File
@@ -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()
+8 -8
View File
@@ -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()
+8 -8
View File
@@ -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()
+8 -8
View File
@@ -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()
+14 -14
View File
@@ -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()
+8 -8
View File
@@ -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 -8
View File
@@ -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()
+8 -8
View File
@@ -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()
+8 -8
View File
@@ -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()