mirror of
https://github.com/LibraHp/GetQzonehistory.git
synced 2024-12-29 07:29:40 +00:00
commit
1a2cedc200
8
.idea/.gitignore
generated
vendored
8
.idea/.gitignore
generated
vendored
@ -1,8 +0,0 @@
|
|||||||
# 默认忽略的文件
|
|
||||||
/shelf/
|
|
||||||
/workspace.xml
|
|
||||||
# 基于编辑器的 HTTP 客户端请求
|
|
||||||
/httpRequests/
|
|
||||||
# Datasource local storage ignored files
|
|
||||||
/dataSources/
|
|
||||||
/dataSources.local.xml
|
|
52
main.py
52
main.py
@ -1,3 +1,4 @@
|
|||||||
|
from datetime import datetime
|
||||||
import platform
|
import platform
|
||||||
import subprocess
|
import subprocess
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
@ -22,6 +23,56 @@ def signal_handler(signal, frame):
|
|||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
|
|
||||||
|
# 还原QQ空间网页版说说
|
||||||
|
def render_html(shuoshuo_path, zhuanfa_path):
|
||||||
|
# 读取 Excel 文件内容
|
||||||
|
shuoshuo_df = pd.read_excel(shuoshuo_path)
|
||||||
|
zhuanfa_df = pd.read_excel(zhuanfa_path)
|
||||||
|
# 头像
|
||||||
|
avatar_url = f"https://q.qlogo.cn/headimg_dl?dst_uin={Request.uin}&spec=640&img_type=jpg"
|
||||||
|
# 提取说说列表中的数据
|
||||||
|
shuoshuo_data = shuoshuo_df[['时间', '内容', '图片链接']].values.tolist()
|
||||||
|
# 提取转发列表中的数据
|
||||||
|
zhuanfa_data = zhuanfa_df[['时间', '内容', '图片链接']].values.tolist()
|
||||||
|
# 合并所有数据
|
||||||
|
all_data = shuoshuo_data + zhuanfa_data
|
||||||
|
# 按时间排序
|
||||||
|
all_data.sort(key=lambda x: datetime.strptime(x[0], "%Y年%m月%d日 %H:%M"), reverse=True)
|
||||||
|
html_template, post_template = Tools.get_html_template()
|
||||||
|
# 构建动态内容
|
||||||
|
post_html = ""
|
||||||
|
for entry in all_data:
|
||||||
|
try:
|
||||||
|
time, content, img_url = entry
|
||||||
|
img_url = str(img_url)
|
||||||
|
content_lst = content.split(":")
|
||||||
|
if len(content_lst) == 1:
|
||||||
|
continue
|
||||||
|
nickname = content_lst[0]
|
||||||
|
message = content_lst[1]
|
||||||
|
|
||||||
|
image_html = f'<div class="image"><img src="{img_url}" alt="图片"></div>' if img_url and img_url.startswith(
|
||||||
|
'http') else ''
|
||||||
|
|
||||||
|
# 生成每个动态的HTML块
|
||||||
|
post_html += post_template.format(
|
||||||
|
avatar_url=avatar_url,
|
||||||
|
nickname=nickname,
|
||||||
|
time=time,
|
||||||
|
message=message,
|
||||||
|
image=image_html
|
||||||
|
)
|
||||||
|
except Exception as err:
|
||||||
|
print(err)
|
||||||
|
|
||||||
|
# 生成完整的HTML
|
||||||
|
final_html = html_template.format(posts=post_html)
|
||||||
|
user_save_path = Config.result_path + Request.uin + '/'
|
||||||
|
# 将HTML写入文件
|
||||||
|
output_file = os.path.join(os.getcwd(), user_save_path, Request.uin + "_说说网页版.html")
|
||||||
|
with open(output_file, 'w', encoding='utf-8') as f:
|
||||||
|
f.write(final_html)
|
||||||
|
|
||||||
|
|
||||||
def save_data():
|
def save_data():
|
||||||
user_save_path = Config.result_path + Request.uin + '/'
|
user_save_path = Config.result_path + Request.uin + '/'
|
||||||
@ -64,6 +115,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)
|
||||||
|
render_html(user_save_path + Request.uin + '_说说列表.xlsx', user_save_path + Request.uin + '_转发列表.xlsx')
|
||||||
Tools.show_author_info()
|
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')
|
||||||
|
@ -55,3 +55,81 @@ def show_author_info():
|
|||||||
print(f'{RED}程序完全免费,且在github开源!!!!{RESET}')
|
print(f'{RED}程序完全免费,且在github开源!!!!{RESET}')
|
||||||
print(f'{RED}程序完全免费,且在github开源!!!!{RESET}')
|
print(f'{RED}程序完全免费,且在github开源!!!!{RESET}')
|
||||||
print(f'{RED}程序完全免费,且在github开源!!!!{RESET}')
|
print(f'{RED}程序完全免费,且在github开源!!!!{RESET}')
|
||||||
|
|
||||||
|
|
||||||
|
def get_html_template():
|
||||||
|
# HTML模板
|
||||||
|
html_template = """
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="zh-CN">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>QQ空间动态</title>
|
||||||
|
<style>
|
||||||
|
body {{
|
||||||
|
font-family: Arial, sans-serif;
|
||||||
|
background-color: #f5f5f5;
|
||||||
|
}}
|
||||||
|
.post {{
|
||||||
|
background-color: #333;
|
||||||
|
color: #fff;
|
||||||
|
padding: 20px;
|
||||||
|
margin: 20px;
|
||||||
|
border-radius: 10px;
|
||||||
|
}}
|
||||||
|
.avatar {{
|
||||||
|
float: left;
|
||||||
|
margin-right: 20px;
|
||||||
|
}}
|
||||||
|
.content {{
|
||||||
|
overflow: hidden;
|
||||||
|
}}
|
||||||
|
.avatar img {{
|
||||||
|
width: 50px;
|
||||||
|
height: 50px;
|
||||||
|
border-radius: 50%;
|
||||||
|
}}
|
||||||
|
.nickname {{
|
||||||
|
font-size: 1.2em;
|
||||||
|
font-weight: bold;
|
||||||
|
}}
|
||||||
|
.time {{
|
||||||
|
color: #999;
|
||||||
|
font-size: 0.9em;
|
||||||
|
}}
|
||||||
|
.message {{
|
||||||
|
margin-top: 10px;
|
||||||
|
font-size: 1.1em;
|
||||||
|
}}
|
||||||
|
.image {{
|
||||||
|
margin-top: 10px;
|
||||||
|
}}
|
||||||
|
.image img {{
|
||||||
|
max-width: 100%;
|
||||||
|
border-radius: 10px;
|
||||||
|
}}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
{posts}
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
"""
|
||||||
|
|
||||||
|
# 生成每个动态的HTML内容
|
||||||
|
post_template = """
|
||||||
|
<div class="post">
|
||||||
|
<div class="avatar">
|
||||||
|
<img src="{avatar_url}" alt="头像">
|
||||||
|
</div>
|
||||||
|
<div class="content">
|
||||||
|
<div class="nickname">{nickname}</div>
|
||||||
|
<div class="time">{time}</div>
|
||||||
|
<div class="message">{message}</div>
|
||||||
|
{image}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
"""
|
||||||
|
|
||||||
|
return html_template, post_template
|
||||||
|
Loading…
Reference in New Issue
Block a user