{"record":{"id":"5bb335a6c6f7c855","repo":"jackwener/OpenCLI","slug":"weibo-favorites","errorCode":null,"errorMessage":"weibo favorites","messagePattern":"weibo favorites","errorType":"exception","errorClass":"EmptyResultError","httpStatus":null,"severity":"info","filePath":"clis/weibo/favorites.js","lineNumber":151,"sourceCode":"          // innerText preserves newlines between block elements (unlike textContent)\n          const rawText = bodyEl.innerText || s.innerText || '';\n\n          let postUrl = '';\n          const anchors = s.querySelectorAll('a[href]');\n          for (const a of anchors) {\n            const m = String(a.href).match(/weibo\\\\.com\\\\/(\\\\d+)\\\\/([a-zA-Z0-9]+)/);\n            if (m) { postUrl = 'https://weibo.com/' + m[1] + '/' + m[2]; break; }\n          }\n\n          if (rawText.length > 20) out.push({ text: rawText, url: postUrl });\n          if (out.length >= ${limit}) break;\n        }\n        return out;\n      })()\n    `)), 'weibo favorites');\n\n    if (rawData.length === 0) {\n      throw new EmptyResultError('weibo favorites', 'No favorites were visible on the favorites page');\n    }\n\n    const items = rawData\n      .map(card => parseFavoriteCard(card, favUrl))\n      .filter(Boolean);\n\n    const uniqueItems = dedupeFavorites(items, favUrl);\n    if (uniqueItems.length === 0) {\n      throw new CommandExecutionError('Failed to parse visible Weibo favorites');\n    }\n    return uniqueItems.slice(0, limit);\n  },\n});\n\nexport const __test__ = {\n  parseFavoriteCard,\n  parsePositiveInt,\n  dedupeFavorites,","sourceCodeStart":133,"sourceCodeEnd":169,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/weibo/favorites.js#L133-L169","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nconst favs = await cli.run('weibo favorites', {});\n// after\nlet favs;\ntry {\n  favs = await cli.run('weibo favorites', {});\n} catch (e) {\n  if (e instanceof EmptyResultError) favs = [];\n  else throw e;\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function isEmptyFavorites(e) { return e instanceof Error && e.name === 'EmptyResultError' && /No favorites/.test(e.message); }","tryCatchPattern":"let favorites = [];\ntry {\n  favorites = await cli.run('weibo favorites', { limit });\n} catch (e) {\n  if (!isEmptyFavorites(e)) throw e; // empty favorites is a normal state\n}","preventionTips":["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"],"tags":["weibo","empty-result","scraping","no-data"],"backgroundTag":"empty-result-set","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}