Update IPTV搜索引擎采集.py
This commit is contained in:
+3
-5
@@ -417,8 +417,7 @@ def check_and_write_file(input_file, output_file, keywords):
|
|||||||
print(f"未提取到关键词,不创建输出文件 {output_file}。")
|
print(f"未提取到关键词,不创建输出文件 {output_file}。")
|
||||||
|
|
||||||
# 按类别提取关键词并写入文件
|
# 按类别提取关键词并写入文件
|
||||||
check_and_write_file('2.txt', '主.txt', keywords="央视频道, 8K, 4K, 4k")
|
check_and_write_file('2.txt', 'a.txt', keywords="央视频道, CCTV, CHC, 全球大片, 星光院线, 8K, 4K, 4k")
|
||||||
check_and_write_file('2.txt', 'a.txt', keywords="央视频道, CCTV, CHC, 全球大片, 星光院线")
|
|
||||||
check_and_write_file('2.txt', 'b.txt', keywords="卫视频道, 卫视, 凤凰, 星空")
|
check_and_write_file('2.txt', 'b.txt', keywords="卫视频道, 卫视, 凤凰, 星空")
|
||||||
check_and_write_file('2.txt', 'c0.txt', keywords="组播剧场, 第一剧场, 怀旧剧场, 风云音乐, 风云剧场, 欢笑剧场, 都市剧场, 高清电影, 家庭影院, 动作电影, 影迷, 峨眉, 重温, 女性, 地理")
|
check_and_write_file('2.txt', 'c0.txt', keywords="组播剧场, 第一剧场, 怀旧剧场, 风云音乐, 风云剧场, 欢笑剧场, 都市剧场, 高清电影, 家庭影院, 动作电影, 影迷, 峨眉, 重温, 女性, 地理")
|
||||||
check_and_write_file('2.txt', 'c.txt', keywords="组播剧场, 爱动漫, SiTV, 爱怀旧, 爱经典, 爱科幻, 爱青春, 爱悬疑, 爱幼教, 爱院线")
|
check_and_write_file('2.txt', 'c.txt', keywords="组播剧场, 爱动漫, SiTV, 爱怀旧, 爱经典, 爱科幻, 爱青春, 爱悬疑, 爱幼教, 爱院线")
|
||||||
@@ -427,7 +426,7 @@ check_and_write_file('2.txt', 'e.txt', keywords="北京频道, 北京")
|
|||||||
###############################################################################################################################################################################################################################
|
###############################################################################################################################################################################################################################
|
||||||
##############################################################对生成的文件进行合并
|
##############################################################对生成的文件进行合并
|
||||||
file_contents = []
|
file_contents = []
|
||||||
file_paths = ["主.txt", "a.txt", "a1.txt", "b.txt", "c0.txt", "c.txt", "d.txt", "e0.txt", "e.txt"] # 替换为实际的文件路径列表
|
file_paths = ["a.txt", "b.txt", "c0.txt", "c.txt", "d.txt", "e.txt"] # 替换为实际的文件路径列表
|
||||||
for file_path in file_paths:
|
for file_path in file_paths:
|
||||||
if os.path.exists(file_path):
|
if os.path.exists(file_path):
|
||||||
with open(file_path, 'r', encoding="utf-8") as file:
|
with open(file_path, 'r', encoding="utf-8") as file:
|
||||||
@@ -613,8 +612,7 @@ with open(file_path, 'r+', encoding='utf-8') as f:
|
|||||||
|
|
||||||
|
|
||||||
################################################################################################任务结束,删除不必要的过程文件
|
################################################################################################任务结束,删除不必要的过程文件
|
||||||
files_to_remove = ['去重.txt', '分类.txt', "2.txt", "4.txt", "5.txt", "主.txt", "a.txt", "a1.txt", "b.txt", "c0.txt", "c.txt", "d.txt", \
|
files_to_remove = ['去重.txt', '分类.txt', "2.txt", "4.txt", "5.txt", "a.txt", "b.txt", "c0.txt", "c.txt", "d.txt", "e.txt"]
|
||||||
"e0.txt", "e.txt"]
|
|
||||||
for file in files_to_remove:
|
for file in files_to_remove:
|
||||||
if os.path.exists(file):
|
if os.path.exists(file):
|
||||||
os.remove(file)
|
os.remove(file)
|
||||||
|
|||||||
Reference in New Issue
Block a user