|
|
@ -126,7 +126,6 @@ for page in range(1,8):
|
|
|
|
|
|
|
|
|
|
|
|
ai_list = []
|
|
|
|
ai_list = []
|
|
|
|
most_common_barrages = []
|
|
|
|
most_common_barrages = []
|
|
|
|
|
|
|
|
|
|
|
|
with open('弹幕.txt', 'r', encoding='utf-8') as file:
|
|
|
|
with open('弹幕.txt', 'r', encoding='utf-8') as file:
|
|
|
|
content_txt = file.readlines()
|
|
|
|
content_txt = file.readlines()
|
|
|
|
for barrage in content_txt:
|
|
|
|
for barrage in content_txt:
|
|
|
@ -141,17 +140,14 @@ ai_list1 = counter.most_common()
|
|
|
|
# 输出结果
|
|
|
|
# 输出结果
|
|
|
|
for barrage, count in most_common_barrages:
|
|
|
|
for barrage, count in most_common_barrages:
|
|
|
|
print(f'弹幕: {barrage} 出现次数: {count}')
|
|
|
|
print(f'弹幕: {barrage} 出现次数: {count}')
|
|
|
|
|
|
|
|
|
|
|
|
df = pd.DataFrame(ai_list1, columns=['弹幕', '出现次数'])
|
|
|
|
df = pd.DataFrame(ai_list1, columns=['弹幕', '出现次数'])
|
|
|
|
# 写入Excel文件
|
|
|
|
# 写入Excel文件
|
|
|
|
excel_path = '弹幕统计.xlsx'
|
|
|
|
excel_path = '弹幕统计.xlsx'
|
|
|
|
df.to_excel(excel_path, index=False, engine='openpyxl')
|
|
|
|
df.to_excel(excel_path, index=False, engine='openpyxl')
|
|
|
|
|
|
|
|
|
|
|
|
wb = load_workbook(excel_path)
|
|
|
|
wb = load_workbook(excel_path)
|
|
|
|
ws = wb.active
|
|
|
|
ws = wb.active
|
|
|
|
|
|
|
|
|
|
|
|
ws.column_dimensions['A'].width = 60
|
|
|
|
ws.column_dimensions['A'].width = 60
|
|
|
|
|
|
|
|
|
|
|
|
wb.save(excel_path)
|
|
|
|
wb.save(excel_path)
|
|
|
|
|
|
|
|
|
|
|
|
ai_str = '\n'.join(ai_list) #分割成字符型
|
|
|
|
ai_str = '\n'.join(ai_list) #分割成字符型
|
|
|
|
|
|
|
|
# 创建词云图
|
|
|
|
|
|
|
|
#create_wordcloud(ai_danmakus)
|