mirror of
https://github.com/jackwener/OpenCLI.git
synced 2026-09-14 18:25:42 +08:00
30b79d4813
- 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()
23 lines
801 B
TypeScript
23 lines
801 B
TypeScript
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,
|
||
}));
|
||
},
|
||
});
|