Files
jackwener__opencli/clis/xueqiu/groups.ts
jackwener 30b79d4813 refactor(adapters): migrate pipeline adapters to func() with { error, help } pattern
- slock: agents, channels, messages, servers now use getSlockContext/resolveChannelId
  from utils.ts; error handling uses { error, help } return instead of bare throws
- linux-do: export fetchLinuxDoJson from feed.ts; migrate search, topic, categories,
  tags, user-posts, user-topics from pipeline+throw to func() using fetchLinuxDoJson
- xueqiu: add utils.ts with fetchXueqiuJson helper; migrate hot, feed, search, stock,
  watchlist, hot-stock, groups, kline, earnings-date from pipeline+throw to func()
2026-04-10 02:18:39 +08:00

23 lines
801 B
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { cli } from '@jackwener/opencli/registry';
import { fetchXueqiuJson } from './utils.js';
cli({
site: 'xueqiu',
name: 'groups',
description: '获取雪球自选股分组列表(含模拟组合)',
domain: 'xueqiu.com',
browser: true,
columns: ['pid', 'name', 'count'],
func: async (page, _kwargs) => {
await page.goto('https://xueqiu.com');
const d = await fetchXueqiuJson(page, 'https://stock.xueqiu.com/v5/stock/portfolio/list.json?category=1&size=20');
if ('error' in d) return [d];
if (!d.data?.stocks) return [{ error: '获取失败', help: '请确认已登录雪球(https://xueqiu.com)' }];
return ((d.data.stocks || []) as any[]).map((g: any) => ({
pid: String(g.id),
name: g.name,
count: g.symbol_count || 0,
}));
},
});