jackwener/OpenCLI · error · AuthRequiredError
xueqiu.com
Error message
xueqiu.com
What it means
The xueqiu hot-stock command fetches the hot-stock list from stock.xueqiu.com/v5/stock/hot_stock/list.json after priming the session at xueqiu.com. If the response lacks data.items, it throws AuthRequiredError('xueqiu.com') because the hot-stock endpoint also requires a logged-in session. The error signals the user must authenticate before this data is available.
Source
Thrown at clis/xueqiu/hot-stock.js:21
import { fetchXueqiuJson } from './utils.js';
cli({
site: 'xueqiu',
name: 'hot-stock',
access: 'read',
description: '获取雪球热门股票榜',
domain: 'xueqiu.com',
browser: true,
args: [
{ name: 'limit', type: 'int', default: 20, help: '返回数量,默认 20,最大 50' },
{ name: 'type', default: '10', help: '榜单类型 10=人气榜(默认) 12=关注榜' },
],
columns: ['rank', 'symbol', 'name', 'price', 'changePercent', 'heat'],
func: async (page, kwargs) => {
await page.goto('https://xueqiu.com');
const url = `https://stock.xueqiu.com/v5/stock/hot_stock/list.json?size=${kwargs.limit}&type=${kwargs.type}`;
const d = await fetchXueqiuJson(page, url);
if (!d.data?.items)
throw new AuthRequiredError('xueqiu.com');
return (d.data.items || []).map((s, i) => ({
rank: i + 1,
symbol: s.symbol,
name: s.name,
price: s.current,
changePercent: s.percent != null ? s.percent.toFixed(2) + '%' : null,
heat: s.value,
url: 'https://xueqiu.com/S/' + s.symbol,
}));
},
});
View on GitHub (pinned to 49907e53dc)
Solutions
- Log in to xueqiu.com in the browser used by the CLI, then re-run the command
- Reuse a persisted logged-in browser profile instead of a fresh one
- Inspect the API response for xueqiu auth error codes to confirm the session is invalid
- Retry later if xueqiu is throttling the session
Defensive patterns
Strategy: try-catch
Validate before calling
const d = await fetchXueqiuJson(page, `https://stock.xueqiu.com/v5/stock/hot_stock/list.json?size=${limit}&type=${type}`);
if (!d || d.error_code || !d.data?.items) {
throw new Error('Hot-stock list unavailable — xueqiu session likely unauthenticated (log in to xueqiu.com).');
} Type guard
function hasHotStocks(d) {
return Boolean(d && typeof d === 'object' && d.data && Array.isArray(d.data.items));
} Try / catch
try {
const hot = await xueqiuHotStock({ limit: 20, type: '10' });
} catch (e) {
if (e instanceof AuthRequiredError || /xueqiu\.com/.test(e.message)) {
console.error('Session expired: log in to xueqiu.com and retry.');
} else throw e;
} Prevention
- Verify xueqiu login status before batch runs (e.g. fetch a cheap authed endpoint first)
- Persist cookies/profile so sessions survive restarts
- Detect xueqiu error codes in the raw response to distinguish auth vs rate-limit issues
- Re-login proactively when you see repeated AuthRequiredError
When it happens
Trigger: Invoking the hot-stock command with an unauthenticated or expired xueqiu session so the API returns an error payload without data.items; also when xueqiu returns success:false for the request.
Common situations: Session cookies expired between runs; user cleared browser data; running in a fresh container/browser without a logged-in profile; xueqiu anti-bot measures logged the session out.
Related errors
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/8bde25949f35aa95.
Report an issue: GitHub.