jackwener/OpenCLI · info · EmptyResultError
weibo favorites
Error message
weibo favorites
What it means
clis/weibo/favorites.js:151 throws EmptyResultError('weibo favorites', 'No favorites were visible on the favorites page') when the scrape script ran successfully but returned zero raw cards from the favorites page. The library distinguishes 'page loaded but empty' from auth or HTTP failures.
Source
Thrown at clis/weibo/favorites.js:151
// innerText preserves newlines between block elements (unlike textContent)
const rawText = bodyEl.innerText || s.innerText || '';
let postUrl = '';
const anchors = s.querySelectorAll('a[href]');
for (const a of anchors) {
const m = String(a.href).match(/weibo\\.com\\/(\\d+)\\/([a-zA-Z0-9]+)/);
if (m) { postUrl = 'https://weibo.com/' + m[1] + '/' + m[2]; break; }
}
if (rawText.length > 20) out.push({ text: rawText, url: postUrl });
if (out.length >= ${limit}) break;
}
return out;
})()
`)), 'weibo favorites');
if (rawData.length === 0) {
throw new EmptyResultError('weibo favorites', 'No favorites were visible on the favorites page');
}
const items = rawData
.map(card => parseFavoriteCard(card, favUrl))
.filter(Boolean);
const uniqueItems = dedupeFavorites(items, favUrl);
if (uniqueItems.length === 0) {
throw new CommandExecutionError('Failed to parse visible Weibo favorites');
}
return uniqueItems.slice(0, limit);
},
});
export const __test__ = {
parseFavoriteCard,
parsePositiveInt,
dedupeFavorites,View on GitHub (pinned to 49907e53dc)
Solutions
- Verify in Chrome that the account's favorites page (weibo.com/fav) actually shows items
- Confirm you are logged into the account whose favorites you intend to read
- If items are visible in Chrome but the CLI returns empty, Weibo likely changed markup — update the CLI
- Handle EmptyResultError as a normal empty state in scripts rather than a hard failure
Example fix
// before
const favs = await cli.run('weibo favorites', {});
// after
let favs;
try {
favs = await cli.run('weibo favorites', {});
} catch (e) {
if (e instanceof EmptyResultError) favs = [];
else throw e;
} Defensive patterns
Strategy: try-catch
Type guard
function isEmptyFavorites(e) { return e instanceof Error && e.name === 'EmptyResultError' && /No favorites/.test(e.message); } Try / catch
let favorites = [];
try {
favorites = await cli.run('weibo favorites', { limit });
} catch (e) {
if (!isEmptyFavorites(e)) throw e; // empty favorites is a normal state
} Prevention
- Treat EmptyResultError as an empty dataset, not a failure
- Confirm the target account has visible favorites before running
- Check you are logged into the intended account in Chrome
- Alert on empty results only when data was expected
When it happens
Trigger: Running `weibo favorites` when the logged-in account has no favorites, the favorites list is empty on the rendered page, or the page rendered no card data (e.g. private/hidden favorites view) so rawData.length === 0.
Common situations: New accounts with nothing favorited; user favorited only posts later deleted by their authors; Weibo A/B test changing the favorites page markup so no cards match; scraping a profile whose favorites tab is hidden.
Understand the failure class
Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.
Related errors
- No coaches for ${fromCity} to ${toCity} on ${date}
- No trains for ${fromName} to ${toName} on ${date}
- EMPTY_RESULT
- No attractions for "${query}"
- No timetable for ${from} to ${to} (${country})
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/5bb335a6c6f7c855.
Report an issue: GitHub.