Skip to content

fix: eastmoney_stock_news 兼容 cmsArticleWebOld 直接返回 list#8

Open
HughHouse wants to merge 1 commit into
simonlin1212:mainfrom
HughHouse:fix/stock-news-list-shape
Open

fix: eastmoney_stock_news 兼容 cmsArticleWebOld 直接返回 list#8
HughHouse wants to merge 1 commit into
simonlin1212:mainfrom
HughHouse:fix/stock-news-list-shape

Conversation

@HughHouse
Copy link
Copy Markdown

问题

eastmoney_stock_news() 在解析东财搜索接口时报错:

AttributeError: 'list' object has no attribute 'get'

定位到 SKILL.md 中:

articles = d.get("result", {}).get("cmsArticleWebOld", {}).get("list", [])

实测(2026-05-20)东财接口 result.cmsArticleWebOld 字段会直接返回文章 list,而不是 {"list": [...]},因此多套的 .get("list") 在 list 上调用就抛异常。

修复

改为对返回类型做自适应:

cw = d.get("result", {}).get("cmsArticleWebOld")
articles = cw if isinstance(cw, list) else (cw or {}).get("list", [])

验证

603019(中科曙光)、688017(绿的谐波) 回归,均能正常返回新闻列表(title/content/time/source/url)。

感谢这个非常实用的工具包 🙏

东财搜索接口 cmsArticleWebOld 字段实测会直接返回文章 list,
而非 {"list": [...]},导致原代码 .get("list") 抛
'list' object has no attribute 'get'。改为类型自适应。

实测 603019/688017 回归通过。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant