get-weibo-trending
Fetch real-time trending topics from Weibo, covering social phenomena, entertainment news, celebrity updates, and other popular Chinese discussions, aggregated by Trends Hub.
Instructions
获取微博热搜榜,包含时事热点、社会现象、娱乐新闻、明星动态及网络热议话题的实时热门中文资讯
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/weibo.ts:7-32 (handler)The handler function fetches Weibo trending topics from the API, filters out ads, constructs search URLs, and returns a list of formatted trending items with title, description, popularity, and link.func: async () => { const resp = await http.get<{ ok: number; data: { realtime: any[]; }; }>('https://weibo.com/ajax/side/hotSearch'); if (resp.data.ok !== 1 || !Array.isArray(resp.data.data.realtime)) { throw new Error('获取微博热搜榜失败'); } return resp.data.data.realtime .filter((item) => item.is_ad !== 1) .map((item: any) => { const key = item.word_scheme || `#${item.word}`; const url = new URL('https://s.weibo.com/weibo'); url.searchParams.set('q', key); url.searchParams.set('band_rank', '1'); url.searchParams.set('Refer', 'top'); return { title: item.word, description: item.note || key, popularity: item.num, link: url.toString(), }; }); },
- src/tools/weibo.ts:4-33 (registration)The tool is registered using defineToolConfig, which defines the name, description, and points to the handler function.export default defineToolConfig({ name: 'get-weibo-trending', description: '获取微博热搜榜,包含时事热点、社会现象、娱乐新闻、明星动态及网络热议话题的实时热门中文资讯', func: async () => { const resp = await http.get<{ ok: number; data: { realtime: any[]; }; }>('https://weibo.com/ajax/side/hotSearch'); if (resp.data.ok !== 1 || !Array.isArray(resp.data.data.realtime)) { throw new Error('获取微博热搜榜失败'); } return resp.data.data.realtime .filter((item) => item.is_ad !== 1) .map((item: any) => { const key = item.word_scheme || `#${item.word}`; const url = new URL('https://s.weibo.com/weibo'); url.searchParams.set('q', key); url.searchParams.set('band_rank', '1'); url.searchParams.set('Refer', 'top'); return { title: item.word, description: item.note || key, popularity: item.num, link: url.toString(), }; }); }, });