sansan преди 5 месеца
родител
ревизия
acb100552d
променени са 4 файла, в които са добавени 54 реда и са изтрити 26 реда
  1. 20 11
      README-EN.md
  2. 19 10
      README.md
  3. 14 4
      main.py
  4. 1 1
      version

+ 20 - 11
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,19 +251,15 @@ 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/20 - v3.1.0
+### 2025/11/22 - v3.1.1
 
-- **Added Personal WeChat Push Support**: WeWork application can push to personal WeChat without installing WeWork APP
-- Supports two message formats: `markdown` (WeWork group bot) and `text` (personal WeChat app)
-- Added `WEWORK_MSG_TYPE` environment variable configuration, supporting GitHub Actions, Docker, docker-compose and other deployment methods
-- `text` mode automatically strips Markdown syntax for clean plain text push
-- See "Personal WeChat Push" configuration in Quick Start
+- **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 updates: `main.py`, `config/config.yaml`
-- Optional update: `.github/workflows/crawler.yml` (if using GitHub Actions)
-- Recommended: Use minor version upgrade method - copy and replace the files above
-
+- Required update: `main.py`
+- Recommended: Use minor version upgrade method - copy and replace the file above
 
 
 ### 2025/11/18 - mcp-v1.0.2
@@ -275,6 +271,19 @@ Transform from "algorithm recommendation captivity" to "actively getting the inf
 <details>
 <summary><strong>👉 Click to expand: Historical Updates</strong></summary>
 
+### 2025/11/20 - v3.1.0
+
+- **Added Personal WeChat Push Support**: WeWork application can push to personal WeChat without installing WeWork APP
+- Supports two message formats: `markdown` (WeWork group bot) and `text` (personal WeChat app)
+- Added `WEWORK_MSG_TYPE` environment variable configuration, supporting GitHub Actions, Docker, docker-compose and other deployment methods
+- `text` mode automatically strips Markdown syntax for clean plain text push
+- See "Personal WeChat Push" configuration in Quick Start
+
+**Upgrade Instructions** (GitHub Fork Users):
+- Required updates: `main.py`, `config/config.yaml`
+- Optional update: `.github/workflows/crawler.yml` (if using GitHub Actions)
+- Recommended: Use minor version upgrade method - copy and replace the files above
+
 ### 2025/11/12 - v3.0.5
 
 - Fixed email sending SSL/TLS port configuration logic error

+ 19 - 10
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,21 +315,17 @@ GitHub 一键 Fork 即可使用,无需编程基础。
 - **大版本升级**:从 v1.x 升级到 v2.y,建议删除现有 fork 后重新 fork,这样更省力且避免配置冲突
 
 
-### 2025/11/20 - v3.1.0
+### 2025/11/22 - v3.1.1
 
-- **新增个人微信推送支持**:企业微信应用可推送到个人微信,无需安装企业微信 APP
-- 支持两种消息格式:`markdown`(企业微信群机器人)和 `text`(个人微信应用)
-- 新增 `WEWORK_MSG_TYPE` 环境变量配置,支持 GitHub Actions、Docker、docker-compose 等多种部署方式
-- `text` 模式自动清除 Markdown 语法,提供纯文本推送效果
-- 详见快速开始中的「个人微信推送」配置说明
+- **修复数据异常导致的崩溃问题**:解决部分用户在 GitHub Actions 环境中遇到的 `'float' object has no attribute 'lower'` 错误
+- 新增双重防护机制:在数据获取阶段过滤无效标题(None、float、空字符串),同时在函数调用处添加类型检查
+- 提升系统稳定性,确保在数据源返回异常格式时仍能正常运行
 
 **升级说明**(GitHub Fork 用户):
-- 必须更新:`main.py`、`config/config.yaml`
-- 可选更新:`.github/workflows/crawler.yml`(如使用 GitHub Actions 部署)
+- 必须更新:`main.py`
 - 建议使用小版本升级方式:复制替换上述文件
 
 
-
 ### 2025/11/18 - mcp-v1.0.2
 
   **MCP 模块更新:**
@@ -339,6 +335,19 @@ GitHub 一键 Fork 即可使用,无需编程基础。
 <details>
 <summary>👉 点击展开:<strong>历史更新</strong></summary>
 
+### 2025/11/20 - v3.1.0
+
+- **新增个人微信推送支持**:企业微信应用可推送到个人微信,无需安装企业微信 APP
+- 支持两种消息格式:`markdown`(企业微信群机器人)和 `text`(个人微信应用)
+- 新增 `WEWORK_MSG_TYPE` 环境变量配置,支持 GitHub Actions、Docker、docker-compose 等多种部署方式
+- `text` 模式自动清除 Markdown 语法,提供纯文本推送效果
+- 详见快速开始中的「个人微信推送」配置说明
+
+**升级说明**(GitHub Fork 用户):
+- 必须更新:`main.py`、`config/config.yaml`
+- 可选更新:`.github/workflows/crawler.yml`(如使用 GitHub Actions 部署)
+- 建议使用小版本升级方式:复制替换上述文件
+
 ### 2025/11/12 - v3.0.5
 
 - 修复邮件发送 SSL/TLS 端口配置逻辑错误

+ 14 - 4
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"]

+ 1 - 1
version

@@ -1 +1 @@
-3.1.0
+3.1.1