大型更新优化

This commit is contained in:
MasonLiu committed 2025-01-22 14:03:36 +08:00
1 parent 71cc3b4d22
commit fd7a51f24b
29 files changed
+3752 -4185

No files matched your search

+47 -20
View File
@@ -107,28 +107,45 @@ def record_md(result, filename="./resources/history/sec_news.md"):
# 写回文件
with open(filename, 'w', encoding='utf-8') as file:
file.write(new_content)
def get_filtered_articles(entries, Is_short):
result = ""
def get_filtered_articles(entries):
result_long = ""
result_short = ""
record = ""
short_results = []
for entry in entries:
if Is_short == False:
result += f"文章:[{entry[1]}]({entry[2]})\n作者:{entry[5]}\n"
result += f"上传时间:{entry[4]}\n"
result += "\n" + "-" * 40 + "\n" # 添加分隔线以便区分不同文章
if Is_short == True:
result += f"文章:[{entry[1]}]({entry[2]})\n"
result += f"链接:{entry[2]}\n上传时间:{entry[4]}\n"
result += "\n" + "-" * 3 + "\n" # 添加分隔线以便区分不同文章
# 构建长文本结果
result_long += f"文章:[{entry[1]}]({entry[2]})\n作者:{entry[5]}\n"
result_long += f"上传时间:{entry[4]}\n"
result_long += "\n" + "-" * 40 + "\n" # 添加分隔线以便区分不同文章
# 构建短文本结果并进行分块处理
current_entry = (
f"文章:[{entry[1]}]({entry[2]})\n"
f"链接:{entry[2]}\n上传时间:{entry[4]}\n"
"\n" + "-" * 3 + "\n" # 添加分隔线以便区分不同文章
)
temp_result = result_short + current_entry
if len(temp_result.encode('utf-8')) > 4096:
short_results.append(result_short)
result_short = current_entry
else:
result_short = temp_result
record += f"#### 文章:[{entry[1]}]({entry[2]})\n"
record += f"**作者**:{entry[5]}\n"
record += f"**上传时间**:{entry[4]}\n"
record += "\n" + "-" * 40 + "\n" # 添加分隔线以便区分不同文章
# 处理最后一个结果
if result_short:
short_results.append(result_short)
record_md(record)
return result
return result_long, short_results
def Src_4hou(e_hour, Is_short):
def Src_4hou(e_hour):
if not os.path.exists('./resources/db/4hou.db'):
# 创建数据库和表
create_database()
@@ -147,17 +164,27 @@ def Src_4hou(e_hour, Is_short):
# print(filtered_articles)
if filtered_articles:
results = get_filtered_articles(filtered_articles, Is_short)
return results
result_long, short_results = get_filtered_articles(filtered_articles)
return result_long, short_results
else:
return ""
return False
if __name__ == "__main__":
reslts = Src_4hou(4, False)
if reslts != "":
print(reslts)
results = Src_4hou(4)
if results != False:
result_long, short_results = results
# 打印长文本结果
print("长文本结果:")
print(result_long)
print("\n" + "-" * 40 + "\n")
# 打印分块的短文本结果
print("分块的短文本结果:")
for short_result in short_results:
print(short_result)
print("\n" + "-" * 40 + "\n")
else:
# 如果为空,则跳过执行
print("-" * 40)
print("嘶吼数据为空,跳过执行。")
print("嘶吼数据为空,跳过执行。")
Binary file not shown.
Binary file not shown.
+46 -18
View File
@@ -102,29 +102,46 @@ def record_md(result, filename="./resources/history/sec_news.md"):
with open(filename, 'w', encoding='utf-8') as file:
file.write(new_content)
def get_filtered_articles(entries, Is_short):
result = ""
def get_filtered_articles(entries):
result_long = ""
result_short = ""
record = ""
short_results = []
for entry in entries:
if Is_short == False:
result += f"文章:[{entry[1]}]({entry[2]})\n作者:{entry[6]}\n来源:{entry[3]}\n"
result += f"上传时间:{entry[5]}\n"
result += "\n" + "-" * 40 + "\n" # 添加分隔线以便区分不同文章
elif Is_short == True:
result += f"文章:{entry[1]}\n"
result += f"链接:{entry[2]}\n上传时间:{entry[5]}\n"
result += "\n" + "-" * 3 + "\n" # 添加分隔线以便区分不同文章
# 构建长文本结果
result_long += f"文章:[{entry[1]}]({entry[2]})\n作者:{entry[6]}\n来源:{entry[3]}\n"
result_long += f"上传时间:{entry[5]}\n"
result_long += "\n" + "-" * 40 + "\n" # 添加分隔线以便区分不同文章
# 构建短文本结果并进行分块处理
current_entry = (
f"文章:{entry[1]}\n"
f"链接:{entry[2]}\n上传时间:{entry[5]}\n"
"\n" + "-" * 3 + "\n" # 添加分隔线以便区分不同文章
)
temp_result = result_short + current_entry
if len(temp_result.encode('utf-8')) > 4096:
short_results.append(result_short)
result_short = current_entry
else:
result_short = temp_result
record += f"#### 文章:[{entry[1]}]({entry[2]})\n"
record += f"**作者**:{entry[6]}\n"
record += f"**来源**:{entry[3]}\n"
record += f"**上传时间**:{entry[5]}\n"
record += "\n" + "-" * 40 + "\n" # 添加分隔线以便区分不同文章
# 处理最后一个结果
if result_short:
short_results.append(result_short)
record_md(record)
return result
return result_long, short_results
def Src_anquanke(e_hour, Is_short):
def Src_anquanke(e_hour):
if not os.path.exists('./resources/db/anquanke.db'):
# 创建数据库和表
create_database()
@@ -143,16 +160,27 @@ def Src_anquanke(e_hour, Is_short):
# print(filtered_articles)
if filtered_articles:
results = get_filtered_articles(filtered_articles, Is_short)
return results
result_long, short_results = get_filtered_articles(filtered_articles)
return result_long, short_results
else:
return False
if __name__ == "__main__":
reslts = Src_anquanke(4, False)
if reslts != False:
print(reslts)
results = Src_anquanke(4)
if results != False:
result_long, short_results = results
# 打印长文本结果
print("长文本结果:")
print(result_long)
print("\n" + "-" * 40 + "\n")
# 打印分块的短文本结果
print("分块的短文本结果:")
for short_result in short_results:
print(short_result)
print("\n" + "-" * 40 + "\n")
else:
# 如果为空,则跳过执行
print("-" * 40)
print("安全客数据为空,跳过执行。")
print("安全客数据为空,跳过执行。")
+50 -21
View File
@@ -137,30 +137,48 @@ def record_md(result, filename="./resources/history/baidu_news.md"):
with open(filename, 'w', encoding='utf-8') as file:
file.write(new_content)
def get_filtered_articles(entries, Is_short):
result = ""
def get_filtered_articles(entries):
result_long = ""
result_short = ""
record = ""
short_results = []
for entry in entries:
if Is_short == False:
result += f"文章:[{entry[1]}]({entry[2]})\n描述:{entry[3]}\n"
result += f"发布时间:{entry[4]}\n"
result += f"来源:{entry[5]}\n"
result += f"关键词:{entry[6]}\n"
result += "\n" + "-" * 40 + "\n" # 添加分隔线以便区分不同文章
if Is_short == True:
result += f"文章:[{entry[1]}]({entry[2]})"
result += f"上传时间:{entry[4]}\n"
result += "\n" + "-" * 3 + "\n" # 添加分隔线以便区分不同文章
# 构建长文本结果
result_long += f"文章:[{entry[1]}]({entry[2]})\n描述:{entry[3]}\n"
result_long += f"发布时间:{entry[4]}\n"
result_long += f"来源:{entry[5]}\n"
result_long += f"关键词:{entry[6]}\n"
result_long += "\n" + "-" * 40 + "\n" # 添加分隔线以便区分不同文章
# 构建短文本结果并进行分块处理
current_entry = (
f"文章:[{entry[1]}]({entry[2]})"
f"上传时间:{entry[4]}\n"
"\n" + "-" * 3 + "\n" # 添加分隔线以便区分不同文章
)
temp_result = result_short + current_entry
if len(temp_result.encode('utf-8')) > 4096:
short_results.append(result_short)
result_short = current_entry
else:
result_short = temp_result
record += f"#### 文章:[{entry[1]}]({entry[2]})\n描述:{entry[3]}\n"
record += f"**上传时间**:{entry[4]}\n"
record += f"**来源**:{entry[5]}\n"
record += f"**关键词**:{entry[6]}\n"
record += "\n" + "-" * 40 + "\n" # 添加分隔线以便区分不同文章
record_md(record)
return result
def Src_baidu(Is_short):
# 处理最后一个结果
if result_short:
short_results.append(result_short)
record_md(record)
return result_long, short_results
def Src_baidu():
if not os.path.exists('./resources/db/baidu.db'):
# 创建数据库和表
create_database()
@@ -179,16 +197,27 @@ def Src_baidu(Is_short):
# print(filtered_articles)
if filtered_articles:
results = get_filtered_articles(filtered_articles, Is_short)
return results
result_long, short_results = get_filtered_articles(filtered_articles)
return result_long, short_results
else:
return False
if __name__ == "__main__":
reslts = Src_baidu(False)
if reslts != False:
print(reslts)
results = Src_baidu()
if results != False:
result_long, short_results = results
# 打印长文本结果
print("长文本结果:")
print(result_long)
print("\n" + "-" * 40 + "\n")
# 打印分块的短文本结果
print("分块的短文本结果:")
for short_result in short_results:
print(short_result)
print("\n" + "-" * 40 + "\n")
else:
# 如果为空,则跳过执行
print("-" * 40)
print("微信公众号数据为空,跳过执行。")
print("百度数据为空,跳过执行。")
+50 -21
View File
@@ -147,31 +147,49 @@ def record_md(result, filename="./resources/history/tech_passage.md"):
with open(filename, 'w', encoding='utf-8') as file:
file.write(new_content)
def get_filtered_articles(entries, Is_short):
result = ""
def get_filtered_articles(entries):
result_long = ""
result_short = ""
record = ""
short_results = []
for entry in entries:
if Is_short == False:
result += f"文章:[{entry[1]}]({entry[2]})\n"
result += f"作者:{entry[5]}\n"
result += f"上传时间:{entry[4]}\n"
result += f"简介:{entry[3]}\n"
result += "\n" + "-" * 40 + "\n" # 添加分隔线以便区分不同文章
if Is_short == True:
result += f"文章:[{entry[1]}]({entry[2]})\n"
result += f"上传时间:{entry[4]}\n"
result += "\n" + "-" * 3 + "\n" # 添加分隔线以便区分不同文章
# 构建长文本结果
result_long += f"文章:[{entry[1]}]({entry[2]})\n"
result_long += f"作者:{entry[5]}\n"
result_long += f"上传时间:{entry[4]}\n"
result_long += f"简介:{entry[3]}\n"
result_long += "\n" + "-" * 40 + "\n" # 添加分隔线以便区分不同文章
# 构建短文本结果并进行分块处理
current_entry = (
f"文章:[{entry[1]}]({entry[2]})\n"
f"上传时间:{entry[4]}\n"
"\n" + "-" * 3 + "\n" # 添加分隔线以便区分不同文章
)
temp_result = result_short + current_entry
if len(temp_result.encode('utf-8')) > 4096:
short_results.append(result_short)
result_short = current_entry
else:
result_short = temp_result
record += f"#### 文章:[{entry[1]}]({entry[2]})\n"
record += f"**作者**:{entry[5]}\n"
record += f"**上传时间**:{entry[4]}\n"
record += f"**简介**:{entry[3]}\n"
record += "\n" + "-" * 40 + "\n" # 添加分隔线以便区分不同文章
# 处理最后一个结果
if result_short:
short_results.append(result_short)
record_md(record)
return result
return result_long, short_results
def Src_doonsec(Is_short, Doonsec_switch, Doonsec):
def Src_doonsec(Doonsec_switch, Doonsec):
if not os.path.exists('./resources/db/doonsec.db'):
# 创建数据库和表
create_database()
@@ -180,25 +198,36 @@ def Src_doonsec(Is_short, Doonsec_switch, Doonsec):
# clear_table()
# 获取 JSON 数据
M_doonsec_data = get_doonsec_json()
doonsec_data = get_doonsec_json()
# 插入数据到数据库
insert_data(M_doonsec_data)
insert_data(doonsec_data)
# 查询指定时间段内的数据
filtered_articles = select_articles(Doonsec_switch, Doonsec)
# print(filtered_articles)
if filtered_articles:
results = get_filtered_articles(filtered_articles, Is_short)
return results
result_long, short_results = get_filtered_articles(filtered_articles)
return result_long, short_results
else:
return False
if __name__ == "__main__":
reslts = Src_doonsec(False, False, ["webshell", "2000", "POC", "SQL", "XSS", "CSRF", "漏洞"] )
if reslts != False:
print(reslts)
results = Src_doonsec(False, ["webshell", "2000", "POC", "SQL", "XSS", "CSRF", "漏洞"])
if results != False:
result_long, short_results = results
# 写入长文本结果
with open("./1.txt", "a", encoding="utf-8") as f:
f.write(result_long)
f.write("\n" + "-" * 40 + "\n")
# 写入分块的短文本结果
for short_result in short_results:
with open("./2.txt", "a", encoding="utf-8") as f:
f.write(short_result)
f.write("\n" + "-" * 40 + "\n")
else:
# 如果为空,则跳过执行
print("-" * 40)
+45 -17
View File
@@ -108,28 +108,45 @@ def record_md(result, filename="./resources/history/sec_news.md"):
with open(filename, 'w', encoding='utf-8') as file:
file.write(new_content)
def get_filtered_articles(entries, Is_short):
result = ""
def get_filtered_articles(entries):
result_long = ""
result_short = ""
record = ""
short_results = []
for entry in entries:
if Is_short == False:
result += f"文章:[{entry[1]}]({entry[2]})\n类型:{entry[5]}\n"
result += f"上传时间:{entry[4]}\n"
result += "\n" + "-" * 40 + "\n" # 添加分隔线以便区分不同文章
elif Is_short == True:
result += f"文章:[{entry[1]}]({entry[2]})\n"
result += f"上传时间:{entry[4]}\n"
result += "\n" + "-" * 3 + "\n" # 添加分隔线以便区分不同文章
# 构建长文本结果
result_long += f"文章:[{entry[1]}]({entry[2]})\n类型:{entry[5]}\n"
result_long += f"上传时间:{entry[4]}\n"
result_long += "\n" + "-" * 40 + "\n" # 添加分隔线以便区分不同文章
# 构建短文本结果并进行分块处理
current_entry = (
f"文章:[{entry[1]}]({entry[2]})\n"
f"上传时间:{entry[4]}\n"
"\n" + "-" * 3 + "\n" # 添加分隔线以便区分不同文章
)
temp_result = result_short + current_entry
if len(temp_result.encode('utf-8')) > 4096:
short_results.append(result_short)
result_short = current_entry
else:
result_short = temp_result
record += f"#### 文章:[{entry[1]}]({entry[2]})\n"
record += f"**类型**:{entry[5]}\n"
record += f"**上传时间**:{entry[4]}\n"
record += "\n" + "-" * 40 + "\n" # 添加分隔线以便区分不同文章
# 处理最后一个结果
if result_short:
short_results.append(result_short)
record_md(record)
return result
return result_long, short_results
def Src_freebuf(e_hour, Is_short):
def Src_freebuf(e_hour):
if not os.path.exists('./resources/db/freebuf.db'):
# 创建数据库和表
create_database()
@@ -148,15 +165,26 @@ def Src_freebuf(e_hour, Is_short):
# print(filtered_articles)
if filtered_articles:
results = get_filtered_articles(filtered_articles, Is_short)
return results
result_long, short_results = get_filtered_articles(filtered_articles)
return result_long, short_results
else:
return False
if __name__ == "__main__":
reslts = Src_freebuf(4, False)
if reslts != False:
print(reslts)
results = Src_freebuf(24)
if results != False:
result_long, short_results = results
# 打印长文本结果
print("长文本结果:")
print(result_long)
print("\n" + "-" * 40 + "\n")
# 打印分块的短文本结果
print("分块的短文本结果:")
for short_result in short_results:
print(short_result)
print("\n" + "-" * 40 + "\n")
else:
# 如果为空,则跳过执行
print("-" * 40)
+108 -69
View File
@@ -297,59 +297,81 @@ def record_md(result, filename="./resources/history/github.md"):
with open(filename, 'w', encoding='utf-8') as file:
file.write(new_content)
def get_filtered_articles(entries, Is_short, choice):
result = ""
def get_filtered_articles(entries, choice):
result_long = ""
result_short = ""
record = ""
short_results = []
for entry in entries:
if Is_short == False:
if choice == 1:
result += f"关键词【{entry[6]}】发现新项目:[{entry[1]}]({entry[2]})\n"
result += f"项目描述:{entry[3]}\n"
result += f"上传时间:{entry[4]}\n"
result += f"开发语言:{entry[7]}\t\t作者:{entry[5]}\n"
result += "\n" + "-" * 10 + "\n" # 添加分隔线以便区分不同文章
elif choice == 2:
result += f"项目:[{entry[1]}]({entry[2]})存在更新!!!\n"
result += f"更新描述:{entry[3]}\n"
result += f"更新时间:{entry[4]}\n"
result += f"提交者:{entry[5]},[点此查看提交详情]({entry[7]})\n"
result += "\n" + "-" * 10 + "\n" # 添加分隔线以便区分不同文章
elif choice == 3:
result += f"大佬 {entry[5]} 上传了一个新工具:[{entry[1]}]({entry[2]})\n"
result += f"项目描述:{entry[3]}\n"
result += f"上传时间:{entry[4]}\n"
result += "\n" + "-" * 10 + "\n" # 添加分隔线以便区分不同文章
elif choice == 4:
result += f"【{entry[3]}】为[{entry[4]}]({entry[1]})发布了新版本,请及时查收!\n"
result += f"发布时间:{entry[2]}\n"
result += "\n" + "-" * 10 + "\n" # 添加分隔线以便区分不同文章
elif Is_short == True:
if choice == 1:
result += f"关键词【{entry[7]}】发现新项目:[{entry[1]}]({entry[2]})\n"
result += f"上传时间:{entry[4]}\n"
result += f"开发语言:{entry[6]}\t\t作者:{entry[5]}\n"
result += "\n" + "-" * 3 + "\n" # 添加分隔线以便区分不同文章
elif choice == 2:
result += f"项目:[{entry[1]}]({entry[2]})存在更新!!!\n"
result += f"更新描述:{entry[3]}\n"
result += f"更新时间:{entry[4]}\n"
result += f"提交者:{entry[5]},[点此查看提交详情]({entry[7]})\n"
result += "\n" + "-" * 3 + "\n" # 添加分隔线以便区分不同文章
elif choice == 3:
result += f"大佬 {entry[5]} 上传了一个新工具:[{entry[1]}]({entry[2]})\n"
result += f"项目描述:{entry[3]}\n"
result += f"上传时间:{entry[4]}\n"
result += "\n" + "-" * 3 + "\n" # 添加分隔线以便区分不同文章
elif choice == 4:
result += f"【{entry[3]}】为[{entry[4]}]({entry[1]})发布了新版本,请及时查收!\n"
result += f"发布时间:{entry[2]}\n"
result += "\n" + "-" * 3 + "\n" # 添加分隔线以便区分不同文章
if choice == 1:
# 构建长文本结果
result_long += f"关键词【{entry[6]}】发现新项目:[{entry[1]}]({entry[2]})\n"
result_long += f"项目描述:{entry[3]}\n"
result_long += f"上传时间:{entry[4]}\n"
result_long += f"开发语言:{entry[7]}\t\t作者:{entry[5]}\n"
result_long += "\n" + "-" * 10 + "\n" # 添加分隔线以便区分不同文章
# 构建短文本结果并进行分块处理
current_entry = (
f"关键词【{entry[6]}】发现新项目:[{entry[1]}]({entry[2]})\n"
f"上传时间:{entry[4]}\n"
f"开发语言:{entry[7]}\t\t作者:{entry[5]}\n"
"\n" + "-" * 3 + "\n" # 添加分隔线以便区分不同文章
)
elif choice == 2:
# 构建长文本结果
result_long += f"项目:[{entry[1]}]({entry[2]})存在更新!!!\n"
result_long += f"更新描述:{entry[3]}\n"
result_long += f"更新时间:{entry[4]}\n"
result_long += f"提交者:{entry[5]},[点此查看提交详情]({entry[7]})\n"
result_long += "\n" + "-" * 10 + "\n" # 添加分隔线以便区分不同文章
# 构建短文本结果并进行分块处理
current_entry = (
f"项目:[{entry[1]}]({entry[2]})存在更新!!!\n"
f"更新时间:{entry[4]}\n"
f"提交者:{entry[5]},[点此查看提交详情]({entry[7]})\n"
"\n" + "-" * 3 + "\n" # 添加分隔线以便区分不同文章
)
elif choice == 3:
# 构建长文本结果
result_long += f"大佬 {entry[5]} 上传了一个新工具:[{entry[1]}]({entry[2]})\n"
result_long += f"项目描述:{entry[3]}\n"
result_long += f"上传时间:{entry[4]}\n"
result_long += "\n" + "-" * 10 + "\n" # 添加分隔线以便区分不同文章
# 构建短文本结果并进行分块处理
current_entry = (
f"大佬 {entry[5]} 上传了一个新工具:[{entry[1]}]({entry[2]})\n"
f"上传时间:{entry[4]}\n"
"\n" + "-" * 3 + "\n" # 添加分隔线以便区分不同文章
)
elif choice == 4:
# 构建长文本结果
result_long += f"【{entry[3]}】为[{entry[4]}]({entry[1]})发布了新版本,请及时查收!\n"
result_long += f"发布时间:{entry[2]}\n"
result_long += "\n" + "-" * 10 + "\n" # 添加分隔线以便区分不同文章
# 构建短文本结果并进行分块处理
current_entry = (
f"【{entry[3]}】为[{entry[4]}]({entry[1]})发布了新版本,请及时查收!\n"
f"发布时间:{entry[2]}\n"
"\n" + "-" * 3 + "\n" # 添加分隔线以便区分不同文章
)
temp_result = result_short + current_entry
if len(temp_result.encode('utf-8')) > 4096:
short_results.append(result_short)
result_short = current_entry
else:
result_short = temp_result
if choice == 1:
record += f"#### 关键词【{entry[7]}】发现新项目:[{entry[1]}]({entry[2]})\n"
record += f"#### 关键词【{entry[6]}】发现新项目:[{entry[1]}]({entry[2]})\n"
record += f"**项目描述**:{entry[3]}\n"
record += f"**上传时间**:{entry[4]}\n"
record += f"**开发语言**:{entry[6]}\n**作者**:{entry[5]}\n"
record += f"**开发语言**:{entry[7]}\n**作者**:{entry[5]}\n"
record += "\n" + "-" * 10 + "\n" # 添加分隔线以便区分不同文章
elif choice == 2:
record += f"#### 项目:[{entry[1]}]({entry[2]})存在更新!!!\n"
@@ -367,11 +389,15 @@ def get_filtered_articles(entries, Is_short, choice):
record += f"**发布时间**:{entry[2]}\n"
record += "\n" + "-" * 10 + "\n" # 添加分隔线以便区分不同文章
# 处理最后一个结果
if result_short:
short_results.append(result_short)
record_md(record)
return result
return result_long, short_results
def Src_github(e_hour, Is_short):
def Src_github(e_hour):
if not os.path.exists('./resources/db/github.db'):
# 创建数据库和表
create_database()
@@ -385,35 +411,48 @@ def Src_github(e_hour, Is_short):
# 查询指定时间段内的数据
keyword_data, repo_data, user_data, release_data = select_articles(e_hour)
results = []
if keyword_data:
result_1 = get_filtered_articles(keyword_data, Is_short, 1)
result_long_1, short_results_1 = get_filtered_articles(keyword_data, 1)
results.append((result_long_1, short_results_1))
else:
result_1 = ""
results.append(("", []))
if repo_data:
result_2 = get_filtered_articles(repo_data, Is_short, 2)
result_long_2, short_results_2 = get_filtered_articles(repo_data, 2)
results.append((result_long_2, short_results_2))
else:
result_2 = ""
results.append(("", []))
if user_data:
result_3 = get_filtered_articles(user_data, Is_short, 3)
result_long_3, short_results_3 = get_filtered_articles(user_data, 3)
results.append((result_long_3, short_results_3))
else:
result_3 = ""
results.append(("", []))
if release_data:
result_4 = get_filtered_articles(release_data, Is_short, 4)
result_long_4, short_results_4 = get_filtered_articles(release_data, 4)
results.append((result_long_4, short_results_4))
else:
result_4 = ""
return result_1, result_2, result_3, result_4
results.append(("", []))
return results
if __name__ == "__main__":
result_1, result_2, result_3, result_4 = Src_github(240, False)
if result_1 != "":
print(result_1)
if result_2 != "":
print(result_2)
if result_3 != "":
print(result_3)
if result_4 != "":
print(result_4)
if result_1 == "" and result_2 == "" and result_3 == "" and result_4 == "":
results = Src_github(240)
for i, (result_long, short_results) in enumerate(results, start=1):
if result_long != "":
print(f"长文本结果 {i}:")
print(result_long)
print("\n" + "-" * 10 + "\n")
if short_results:
print(f"分块的短文本结果 {i}:")
for short_result in short_results:
print(short_result)
print("\n" + "-" * 10 + "\n")
if all(result_long == "" and not short_results for result_long, short_results in results):
# 如果为空,则跳过执行
print("-" * 10)
print("github数据为空,跳过执行。")
print("github数据为空,跳过执行。")
+47 -19
View File
@@ -99,30 +99,47 @@ def record_md(result, filename="./resources/history/tech_passage.md"):
with open(filename, 'w', encoding='utf-8') as file:
file.write(new_content)
def get_filtered_articles(entries, Is_short):
result = ""
def get_filtered_articles(entries):
result_long = ""
result_short = ""
record = ""
short_results = []
for entry in entries:
if Is_short == False:
result += f"文章:[{entry[1]}]({entry[2]})\n来源:{entry[3]}\n"
result += f"上传时间:{entry[5]}\n"
result += f"描述:{entry[4]}\n"
result += "\n" + "-" * 40 + "\n" # 添加分隔线以便区分不同文章
if Is_short == True:
result += f"文章:[{entry[1]}]({entry[2]})\n"
result += f"上传时间:{entry[5]}\n"
result += "\n" + "-" * 3 + "\n" # 添加分隔线以便区分不同文章
# 构建长文本结果
result_long += f"文章:[{entry[1]}]({entry[2]})\n来源:{entry[3]}\n"
result_long += f"上传时间:{entry[5]}\n"
result_long += f"描述:{entry[4]}\n"
result_long += "\n" + "-" * 40 + "\n" # 添加分隔线以便区分不同文章
# 构建短文本结果并进行分块处理
current_entry = (
f"文章:[{entry[1]}]({entry[2]})\n"
f"上传时间:{entry[5]}\n"
"\n" + "-" * 3 + "\n" # 添加分隔线以便区分不同文章
)
temp_result = result_short + current_entry
if len(temp_result.encode('utf-8')) > 4096:
short_results.append(result_short)
result_short = current_entry
else:
result_short = temp_result
record += f"#### 文章:[{entry[1]}]({entry[2]})\n"
record += f"**来源**:{entry[3]}\n"
record += f"**上传时间**:{entry[5]}\n"
record += f"**描述**:{entry[4]}\n"
record += "\n" + "-" * 40 + "\n" # 添加分隔线以便区分不同文章
# 处理最后一个结果
if result_short:
short_results.append(result_short)
record_md(record)
return result
return result_long, short_results
def Src_qianxin(e_hour, Is_short):
def Src_qianxin(e_hour):
if not os.path.exists('./resources/db/qianxin.db'):
# 创建数据库和表
create_database()
@@ -141,16 +158,27 @@ def Src_qianxin(e_hour, Is_short):
# print(filtered_articles)
if filtered_articles:
results = get_filtered_articles(filtered_articles, Is_short)
return results
result_long, short_results = get_filtered_articles(filtered_articles)
return result_long, short_results
else:
return False
if __name__ == "__main__":
reslts = Src_qianxin(4, False)
if reslts != False:
print(reslts)
results = Src_qianxin(4)
if results != False:
result_long, short_results = results
# 打印长文本结果
print("长文本结果:")
print(result_long)
print("\n" + "-" * 40 + "\n")
# 打印分块的短文本结果
print("分块的短文本结果:")
for short_result in short_results:
print(short_result)
print("\n" + "-" * 40 + "\n")
else:
# 如果为空,则跳过执行
print("-" * 40)
print("奇安信攻防社区数据为空,跳过执行。")
print("奇安信攻防社区数据为空,跳过执行。")
+47 -19
View File
@@ -106,30 +106,47 @@ def record_md(result, filename="./resources/history/sec_news.md"):
with open(filename, 'w', encoding='utf-8') as file:
file.write(new_content)
def get_filtered_articles(entries, Is_short):
result = ""
def get_filtered_articles(entries):
result_long = ""
result_short = ""
record = ""
short_results = []
for entry in entries:
if Is_short == False:
result += f"文章:[{entry[1]}]({entry[2]})\n类型:{entry[3]}\n"
result += f"上传时间:{entry[5]}\n"
result += f"{entry[4]}\n"
result += "\n" + "-" * 40 + "\n" # 添加分隔线以便区分不同文章
if Is_short == True:
result += f"文章:[{entry[1]}]({entry[2]})"
result += f"上传时间:{entry[5]}\n"
result += "\n" + "-" * 3 + "\n" # 添加分隔线以便区分不同文章
# 构建长文本结果
result_long += f"文章:[{entry[1]}]({entry[2]})\n类型:{entry[3]}\n"
result_long += f"上传时间:{entry[5]}\n"
result_long += f"{entry[4]}\n"
result_long += "\n" + "-" * 40 + "\n" # 添加分隔线以便区分不同文章
# 构建短文本结果并进行分块处理
current_entry = (
f"文章:[{entry[1]}]({entry[2]})\n"
f"上传时间:{entry[5]}\n"
"\n" + "-" * 3 + "\n" # 添加分隔线以便区分不同文章
)
temp_result = result_short + current_entry
if len(temp_result.encode('utf-8')) > 4096:
short_results.append(result_short)
result_short = current_entry
else:
result_short = temp_result
record += f"#### 文章:[{entry[1]}]({entry[2]})\n"
record += f"**类型**:{entry[3]}\n"
record += f"**上传时间**:{entry[5]}\n"
record += f"{entry[4]}\n"
record += "\n" + "-" * 40 + "\n" # 添加分隔线以便区分不同文章
# 处理最后一个结果
if result_short:
short_results.append(result_short)
record_md(record)
return result
return result_long, short_results
def Src_seebug(e_hour, Is_short):
def Src_seebug(e_hour):
if not os.path.exists('./resources/db/seebug.db'):
# 创建数据库和表
create_database()
@@ -148,16 +165,27 @@ def Src_seebug(e_hour, Is_short):
# print(filtered_articles)
if filtered_articles:
results = get_filtered_articles(filtered_articles, Is_short)
return results
result_long, short_results = get_filtered_articles(filtered_articles)
return result_long, short_results
else:
return False
if __name__ == "__main__":
reslts = Src_seebug(100, False)
if reslts != False:
print(reslts)
results = Src_seebug(100)
if results != False:
result_long, short_results = results
# 打印长文本结果
print("长文本结果:")
print(result_long)
print("\n" + "-" * 40 + "\n")
# 打印分块的短文本结果
print("分块的短文本结果:")
for short_result in short_results:
print(short_result)
print("\n" + "-" * 40 + "\n")
else:
# 如果为空,则跳过执行
print("-" * 40)
print("Seebug社区数据为空,跳过执行。")
print("Seebug社区数据为空,跳过执行。")
+50 -21
View File
@@ -139,30 +139,48 @@ def record_md(result, filename="./resources/history/wx_news.md"):
with open(filename, 'w', encoding='utf-8') as file:
file.write(new_content)
def get_filtered_articles(entries, Is_short):
result = ""
def get_filtered_articles(entries):
result_long = ""
result_short = ""
record = ""
short_results = []
for entry in entries:
if Is_short == False:
result += f"文章:[{entry[1]}]({entry[2]})\n描述:{entry[3]}\n"
result += f"上传时间:{entry[4]}\n"
result += f"作者:{entry[5]}\n"
result += f"关键词:{entry[6]}\n"
result += "\n" + "-" * 40 + "\n" # 添加分隔线以便区分不同文章
if Is_short == True:
result += f"文章:[{entry[1]}]({entry[2]})"
result += f"上传时间:{entry[4]}\n"
result += "\n" + "-" * 3 + "\n" # 添加分隔线以便区分不同文章
# 构建长文本结果
result_long += f"文章:[{entry[1]}]({entry[2]})\n描述:{entry[3]}\n"
result_long += f"上传时间:{entry[4]}\n"
result_long += f"作者:{entry[5]}\n"
result_long += f"关键词:{entry[6]}\n"
result_long += "\n" + "-" * 40 + "\n" # 添加分隔线以便区分不同文章
# 构建短文本结果并进行分块处理
current_entry = (
f"文章:[{entry[1]}]({entry[2]})"
f"上传时间:{entry[4]}\n"
"\n" + "-" * 3 + "\n" # 添加分隔线以便区分不同文章
)
temp_result = result_short + current_entry
if len(temp_result.encode('utf-8')) > 4096:
short_results.append(result_short)
result_short = current_entry
else:
result_short = temp_result
record += f"#### 文章:[{entry[1]}]({entry[2]})\n描述:{entry[3]}\n"
record += f"**上传时间**:{entry[4]}\n"
record += f"**作者**:{entry[5]}\n"
record += f"**关键词**:{entry[6]}\n"
record += "\n" + "-" * 40 + "\n" # 添加分隔线以便区分不同文章
record_md(record)
return result
def Src_sougou_wx(Is_short):
# 处理最后一个结果
if result_short:
short_results.append(result_short)
record_md(record)
return result_long, short_results
def Src_sougou_wx():
if not os.path.exists('./resources/db/sougou-wx.db'):
# 创建数据库和表
create_database()
@@ -181,15 +199,26 @@ def Src_sougou_wx(Is_short):
# print(filtered_articles)
if filtered_articles:
results = get_filtered_articles(filtered_articles, Is_short)
return results
result_long, short_results = get_filtered_articles(filtered_articles)
return result_long, short_results
else:
return False
if __name__ == "__main__":
reslts = Src_sougou_wx(False)
if reslts != False:
print(reslts)
results = Src_sougou_wx()
if results != False:
result_long, short_results = results
# 写入长文本结果
with open("./1.txt", "a", encoding="utf-8") as f:
f.write(result_long)
f.write("\n" + "-" * 40 + "\n")
# 写入分块的短文本结果
for short_result in short_results:
with open("./2.txt", "a", encoding="utf-8") as f:
f.write(short_result)
f.write("\n" + "-" * 40 + "\n")
else:
# 如果为空,则跳过执行
print("-" * 40)
+46 -18
View File
@@ -105,27 +105,44 @@ def record_md(result, filename="./resources/history/tech_passage.md"):
with open(filename, 'w', encoding='utf-8') as file:
file.write(new_content)
def get_filtered_articles(entries, Is_short):
result = ""
def get_filtered_articles(entries):
result_long = ""
result_short = ""
record = ""
short_results = []
for entry in entries:
if Is_short == False:
result += f"文章:[{entry[1]}]({entry[2]})\n"
result += f"上传时间:{entry[3]}\n"
result += "\n" + "-" * 40 + "\n" # 添加分隔线以便区分不同文章
if Is_short == False:
result += f"文章:[{entry[1]}]({entry[2]})\n"
result += f"上传时间:{entry[3]}\n"
result += "\n" + "-" * 3 + "\n" # 添加分隔线以便区分不同文章
# 构建长文本结果
result_long += f"文章:[{entry[1]}]({entry[2]})\n"
result_long += f"上传时间:{entry[3]}\n"
result_long += "\n" + "-" * 40 + "\n" # 添加分隔线以便区分不同文章
# 构建短文本结果并进行分块处理
current_entry = (
f"文章:[{entry[1]}]({entry[2]})\n"
f"上传时间:{entry[3]}\n"
"\n" + "-" * 3 + "\n" # 添加分隔线以便区分不同文章
)
temp_result = result_short + current_entry
if len(temp_result.encode('utf-8')) > 4096:
short_results.append(result_short)
result_short = current_entry
else:
result_short = temp_result
record += f"#### 文章:[{entry[1]}]({entry[2]})\n"
record += f"**上传时间**:{entry[3]}\n"
record += "\n" + "-" * 40 + "\n" # 添加分隔线以便区分不同文章
# 处理最后一个结果
if result_short:
short_results.append(result_short)
record_md(record)
return result
return result_long, short_results
def Src_xianzhi(e_hour, Is_short):
def Src_xianzhi(e_hour):
if not os.path.exists('./resources/db/xianzhi.db'):
# 创建数据库和表
create_database()
@@ -144,16 +161,27 @@ def Src_xianzhi(e_hour, Is_short):
# print(filtered_articles)
if filtered_articles:
results = get_filtered_articles(filtered_articles, Is_short)
return results
result_long, short_results = get_filtered_articles(filtered_articles)
return result_long, short_results
else:
return False
if __name__ == "__main__":
reslts = Src_xianzhi(4, False)
if reslts != False:
print(reslts)
results = Src_xianzhi(124)
if results != False:
result_long, short_results = results
# 打印长文本结果
print("长文本结果:")
print(result_long)
print("\n" + "-" * 40 + "\n")
# 打印分块的短文本结果
print("分块的短文本结果:")
for short_result in short_results:
print(short_result)
print("\n" + "-" * 40 + "\n")
else:
# 如果为空,则跳过执行
print("-" * 40)
print("先知社区数据为空,跳过执行。")
print("先知社区数据为空,跳过执行。")