优化部分代码逻辑

This commit is contained in:
LibraHp_0928 2024-09-12 23:10:29 +08:00
parent 7266360b5e
commit 924b7355af
3 changed files with 33 additions and 8 deletions

9
.gitignore vendored
View File

@ -1,6 +1,9 @@
.idea
**/.DS_Store
**/__pycache__/
/myenv/
resource/temp resource/temp
resource/result resource/result
resource/user resource/user
.idea resource/fetch-all
util/__pycache__
/myenv/

View File

@ -23,11 +23,6 @@ def signal_handler(signal, frame):
def save_data():
df = pd.DataFrame(texts, columns=['时间', '内容'])
df.to_excel(Config.result_path + Request.uin + '.xlsx', index=False)
print('导出成功,请查看 ' + Config.result_path + Request.uin + '.xlsx')
def save_data(): def save_data():
user_save_path = Config.result_path + Request.uin + '/' user_save_path = Config.result_path + Request.uin + '/'
pic_save_path = user_save_path + 'pic/' pic_save_path = user_save_path + 'pic/'
@ -69,6 +64,7 @@ def save_data():
pd.DataFrame(forward_message, columns=['时间', '内容', '图片链接']).to_excel(user_save_path + Request.uin + '_转发列表.xlsx', index=False) pd.DataFrame(forward_message, columns=['时间', '内容', '图片链接']).to_excel(user_save_path + Request.uin + '_转发列表.xlsx', index=False)
pd.DataFrame(leave_message, columns=['时间', '内容', '图片链接']).to_excel(user_save_path + Request.uin + '_留言列表.xlsx', index=False) pd.DataFrame(leave_message, columns=['时间', '内容', '图片链接']).to_excel(user_save_path + Request.uin + '_留言列表.xlsx', index=False)
pd.DataFrame(other_message, columns=['时间', '内容', '图片链接']).to_excel(user_save_path + Request.uin + '_其他列表.xlsx', index=False) pd.DataFrame(other_message, columns=['时间', '内容', '图片链接']).to_excel(user_save_path + Request.uin + '_其他列表.xlsx', index=False)
Tools.show_author_info()
print('\033[36m' + '导出成功,请查看 ' + user_save_path + Request.uin + ' 文件夹内容' + '\033[0m') print('\033[36m' + '导出成功,请查看 ' + user_save_path + Request.uin + ' 文件夹内容' + '\033[0m')
print('\033[32m' + '共有 ' + str(len(texts)) + ' 条消息' + '\033[0m') print('\033[32m' + '共有 ' + str(len(texts)) + ' 条消息' + '\033[0m')
print('\033[36m' + '最早的一条说说发布在' + texts[texts.__len__() - 1][0] + '\033[0m') print('\033[36m' + '最早的一条说说发布在' + texts[texts.__len__() - 1][0] + '\033[0m')

View File

@ -29,3 +29,29 @@ def process_old_html(message):
new_text = extract_string_between(new_text, start_string, end_string) new_text = extract_string_between(new_text, start_string, end_string)
new_text = replace_multiple_spaces(new_text).replace('\\', '') new_text = replace_multiple_spaces(new_text).replace('\\', '')
return new_text return new_text
def show_author_info():
CYAN = '\033[36m'
YELLOW = '\033[33m'
BLUE = '\033[34m'
RESET = '\033[0m'
RED = '\033[31m'
author_art = r'''
'''
print(CYAN + author_art + RESET)
author_info = f"{YELLOW}bilibili{RESET} {BLUE}@高数带我飞{RESET} {YELLOW}GetQzonehistory V1.0{RESET}"
print(author_info)
print(f'{RED}程序完全免费且在github开源{RESET}')
print(f'{RED}程序完全免费且在github开源{RESET}')
print(f'{RED}程序完全免费且在github开源{RESET}')