diff --git a/README-EN.md b/README-EN.md index d7ac1c8..9e1199b 100644 --- a/README-EN.md +++ b/README-EN.md @@ -13,7 +13,7 @@ [![GitHub Stars](https://img.shields.io/github/stars/sansan0/TrendRadar?style=flat-square&logo=github&color=yellow)](https://github.com/sansan0/TrendRadar/stargazers) [![GitHub Forks](https://img.shields.io/github/forks/sansan0/TrendRadar?style=flat-square&logo=github&color=blue)](https://github.com/sansan0/TrendRadar/network/members) [![License](https://img.shields.io/badge/license-GPL--3.0-blue.svg?style=flat-square)](LICENSE) -[![Version](https://img.shields.io/badge/version-v3.1.0-blue.svg)](https://github.com/sansan0/TrendRadar) +[![Version](https://img.shields.io/badge/version-v3.1.1-blue.svg)](https://github.com/sansan0/TrendRadar) [![MCP](https://img.shields.io/badge/MCP-v1.0.2-green.svg)](https://github.com/sansan0/TrendRadar) [![WeWork](https://img.shields.io/badge/WeWork-Notification-00D4AA?style=flat-square)](https://work.weixin.qq.com/) @@ -251,6 +251,26 @@ Transform from "algorithm recommendation captivity" to "actively getting the inf - **Major Version Upgrade**: Upgrading from v1.x to v2.y, recommend deleting existing fork and re-forking to save effort and avoid config conflicts +### 2025/11/22 - v3.1.1 + +- **Fixed data anomaly crash issue**: Resolved `'float' object has no attribute 'lower'` error encountered by some users in GitHub Actions environment +- Added dual protection mechanism: Filter invalid titles (None, float, empty strings) at data acquisition stage, with type checking at function call sites +- Enhanced system stability to ensure normal operation even when data sources return abnormal formats + +**Upgrade Instructions** (GitHub Fork Users): +- Required update: `main.py` +- Recommended: Use minor version upgrade method - copy and replace the file above + + +### 2025/11/18 - mcp-v1.0.2 + + **MCP Module Update:** + - Fix issue where today's news query may return articles from past dates + + +
+👉 Click to expand: Historical Updates + ### 2025/11/20 - v3.1.0 - **Added Personal WeChat Push Support**: WeWork application can push to personal WeChat without installing WeWork APP @@ -264,17 +284,6 @@ Transform from "algorithm recommendation captivity" to "actively getting the inf - Optional update: `.github/workflows/crawler.yml` (if using GitHub Actions) - Recommended: Use minor version upgrade method - copy and replace the files above - - -### 2025/11/18 - mcp-v1.0.2 - - **MCP Module Update:** - - Fix issue where today's news query may return articles from past dates - - -
-👉 Click to expand: Historical Updates - ### 2025/11/12 - v3.0.5 - Fixed email sending SSL/TLS port configuration logic error diff --git a/README.md b/README.md index ecafa61..5cacfd2 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ [![GitHub Stars](https://img.shields.io/github/stars/sansan0/TrendRadar?style=flat-square&logo=github&color=yellow)](https://github.com/sansan0/TrendRadar/stargazers) [![GitHub Forks](https://img.shields.io/github/forks/sansan0/TrendRadar?style=flat-square&logo=github&color=blue)](https://github.com/sansan0/TrendRadar/network/members) [![License](https://img.shields.io/badge/license-GPL--3.0-blue.svg?style=flat-square)](LICENSE) -[![Version](https://img.shields.io/badge/version-v3.1.0-blue.svg)](https://github.com/sansan0/TrendRadar) +[![Version](https://img.shields.io/badge/version-v3.1.1-blue.svg)](https://github.com/sansan0/TrendRadar) [![MCP](https://img.shields.io/badge/MCP-v1.0.2-green.svg)](https://github.com/sansan0/TrendRadar) [![企业微信通知](https://img.shields.io/badge/企业微信-通知-00D4AA?style=flat-square)](https://work.weixin.qq.com/) @@ -315,6 +315,26 @@ GitHub 一键 Fork 即可使用,无需编程基础。 - **大版本升级**:从 v1.x 升级到 v2.y,建议删除现有 fork 后重新 fork,这样更省力且避免配置冲突 +### 2025/11/22 - v3.1.1 + +- **修复数据异常导致的崩溃问题**:解决部分用户在 GitHub Actions 环境中遇到的 `'float' object has no attribute 'lower'` 错误 +- 新增双重防护机制:在数据获取阶段过滤无效标题(None、float、空字符串),同时在函数调用处添加类型检查 +- 提升系统稳定性,确保在数据源返回异常格式时仍能正常运行 + +**升级说明**(GitHub Fork 用户): +- 必须更新:`main.py` +- 建议使用小版本升级方式:复制替换上述文件 + + +### 2025/11/18 - mcp-v1.0.2 + + **MCP 模块更新:** + - 优化查询今日新闻却可能错误返回过去日期的情况 + + +
+👉 点击展开:历史更新 + ### 2025/11/20 - v3.1.0 - **新增个人微信推送支持**:企业微信应用可推送到个人微信,无需安装企业微信 APP @@ -328,17 +348,6 @@ GitHub 一键 Fork 即可使用,无需编程基础。 - 可选更新:`.github/workflows/crawler.yml`(如使用 GitHub Actions 部署) - 建议使用小版本升级方式:复制替换上述文件 - - -### 2025/11/18 - mcp-v1.0.2 - - **MCP 模块更新:** - - 优化查询今日新闻却可能错误返回过去日期的情况 - - -
-👉 点击展开:历史更新 - ### 2025/11/12 - v3.0.5 - 修复邮件发送 SSL/TLS 端口配置逻辑错误 diff --git a/main.py b/main.py index 5080b91..e3c09cc 100644 --- a/main.py +++ b/main.py @@ -20,7 +20,7 @@ import requests import yaml -VERSION = "3.1.0" +VERSION = "3.1.1" # === SMTP邮件配置 === @@ -527,7 +527,11 @@ class DataFetcher: data = json.loads(response) results[id_value] = {} for index, item in enumerate(data.get("items", []), 1): - title = item["title"] + title = item.get("title") + # 跳过无效标题(None、float、空字符串) + if title is None or isinstance(title, float) or not str(title).strip(): + continue + title = str(title).strip() url = item.get("url", "") mobile_url = item.get("mobileUrl", "") @@ -949,6 +953,12 @@ def matches_word_groups( title: str, word_groups: List[Dict], filter_words: List[str] ) -> bool: """检查标题是否匹配词组规则""" + # 防御性类型检查:确保 title 是有效字符串 + if not isinstance(title, str): + title = str(title) if title is not None else "" + if not title.strip(): + return False + # 如果没有配置词组,则匹配所有标题(支持显示全部新闻) if not word_groups: return True @@ -1152,8 +1162,8 @@ def count_word_frequency( source_url = title_data.get("url", "") source_mobile_url = title_data.get("mobileUrl", "") - # 找到匹配的词组 - title_lower = title.lower() + # 找到匹配的词组(防御性转换确保类型安全) + title_lower = str(title).lower() if not isinstance(title, str) else title.lower() for group in word_groups: required_words = group["required"] normal_words = group["normal"] diff --git a/version b/version index a0cd9f0..50e47c8 100644 --- a/version +++ b/version @@ -1 +1 @@ -3.1.0 \ No newline at end of file +3.1.1 \ No newline at end of file