get-theverge-news
Fetch English technology news from The Verge covering innovation, product reviews, internet trends, and company developments.
Instructions
获取 The Verge 新闻,包含科技创新、数码产品评测、互联网趋势及科技公司动态的英文科技资讯
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/theverge.ts:4-31 (handler)The complete tool configuration including the handler function that fetches The Verge RSS using getRss, processes feed entries (handling specific link formats), and returns structured news items with title, description, publish_time, and link.export default defineToolConfig({ name: 'get-theverge-news', description: '获取 The Verge 新闻,包含科技创新、数码产品评测、互联网趋势及科技公司动态的英文科技资讯', func: async () => { const rss = await getRss('https://www.theverge.com/rss/index.xml'); if (!Array.isArray(rss.feed.entry)) { throw new Error('获取 The Verge 新闻失败'); } return (rss.feed.entry as any[]).map((item) => { let link = item.link; if (!link && item.id) { link = item.id; } const url = new URL(link); if (url.searchParams.has('p')) { url.pathname = url.searchParams.get('p') as string; url.search = ''; link = url.toString(); } return { title: item.title, description: item.summary, publish_time: item.published, link, }; }); }, });
- src/utils/rss.ts:4-8 (helper)Helper function to fetch RSS feed XML via HTTP and parse it using fast-xml-parser, used directly in the tool handler.export const getRss = async (url: string) => { const resp = await http.get(url); const parser = new XMLParser(); return parser.parse(resp.data); };