"""
+
+ # 处理失败ID错误信息
if report_data["failed_ids"]:
html += """
-
-
请求失败的平台
-
- """
+
+
⚠️ 请求失败的平台
+
"""
for id_value in report_data["failed_ids"]:
- html += f"- {html_escape(id_value)}
"
+ html += f'- {html_escape(id_value)}
'
html += """
-
-
- """
+
+
"""
- html += """
-
-
- | 排名 |
- 频率词 |
- 出现次数 |
- 占比 |
- 相关标题 |
-
- """
+ # 处理主要统计数据
+ if report_data["stats"]:
+ total_count = len(report_data["stats"])
+
+ for i, stat in enumerate(report_data["stats"], 1):
+ count = stat["count"]
+
+ # 确定热度等级
+ if count >= 10:
+ count_class = "hot"
+ elif count >= 5:
+ count_class = "warm"
+ else:
+ count_class = ""
- for i, stat in enumerate(report_data["stats"], 1):
- formatted_titles = []
+ escaped_word = html_escape(stat["word"])
+
+ html += f"""
+
+ """
- for title_data in stat["titles"]:
- formatted_title = format_title_for_platform("html", title_data)
- formatted_titles.append(formatted_title)
+ # 处理每个词组下的新闻标题,给每条新闻标上序号
+ for j, title_data in enumerate(stat["titles"], 1):
+ is_new = title_data.get("is_new", False)
+ new_class = "new" if is_new else ""
+
+ html += f"""
+
+
{j}
+
+
+
"""
+
+ # 处理标题和链接
+ escaped_title = html_escape(title_data["title"])
+ link_url = title_data.get("mobile_url") or title_data.get("url", "")
+
+ if link_url:
+ escaped_url = html_escape(link_url)
+ html += f'
{escaped_title}'
+ else:
+ html += escaped_title
+
+ html += """
+
+
+
"""
- escaped_word = html_escape(stat["word"])
- html += f"""
-
- | {i} |
- {escaped_word} |
- {stat['count']} |
- {stat.get('percentage', 0)}% |
- {" ".join(formatted_titles)} |
-
- """
-
- html += """
-
- """
+ html += """
+
"""
+ # 处理新增新闻区域
if report_data["new_titles"]:
html += f"""
-