get-9to5mac-news
Fetch Apple-related news from 9to5Mac covering product releases, iOS updates, Mac hardware, app recommendations, and company developments in English.
Instructions
获取 9to5Mac 苹果相关新闻,包含苹果产品发布、iOS 更新、Mac 硬件、应用推荐及苹果公司动态的英文资讯
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/9to5mac.ts:3-7 (registration)Defines and registers the 'get-9to5mac-news' tool configuration, including name, Chinese description, and a parameterless handler that fetches RSS from 9to5Mac feed using getRssItems.export default defineToolConfig({ name: 'get-9to5mac-news', description: '获取 9to5Mac 苹果相关新闻,包含苹果产品发布、iOS 更新、Mac 硬件、应用推荐及苹果公司动态的英文资讯', func: () => getRssItems('https://9to5mac.com/feed/'), });
- src/utils/rss.ts:10-32 (helper)Core helper function that fetches and parses RSS feed XML into structured news items with title, description, category, author, publish time, and link.export const getRssItems = async (url: string) => { const data = await getRss(url); if (!Array.isArray(data.rss?.channel?.item)) { return []; } return (data.rss.channel.item as any[]).map((item) => { let category = ''; if (typeof item.category === 'string') { category = item.category; } if (Array.isArray(item.category)) { category = item.category.join(', '); } return { title: item.title, description: item.description, category, author: item.author || item['dc:creator'], publish_time: item.pubDate, link: item.link, }; }); };
- src/utils/rss.ts:4-8 (helper)Helper function to fetch RSS feed content and parse XML using fast-xml-parser.export const getRss = async (url: string) => { const resp = await http.get(url); const parser = new XMLParser(); return parser.parse(resp.data); };