jackwener/OpenCLI · error · EmptyResultError

Tieba may have blocked the forum page, or the DOM structure

Error message

Tieba may have blocked the forum page, or the DOM structure may have changed

What it means

The tieba posts command fetches the forum page (PC template), builds post cards from payload.page_data.feed_list, and throws EmptyResultError when no items were produced or the payload carries an error_code. This signals the forum page was blocked/empty or the data contract changed.

Source

Thrown at clis/tieba/posts.js:82

    description: 'Browse posts in a tieba forum',
    domain: 'tieba.baidu.com',
    strategy: Strategy.COOKIE,
    browser: true,
    navigateBefore: false,
    args: [
        { name: 'forum', positional: true, required: true, type: 'string', help: 'Forum name in Chinese' },
        { name: 'page', type: 'int', default: 1, help: 'Page number' },
        { name: 'limit', type: 'int', default: 20, help: 'Number of items to return' },
    ],
    columns: ['rank', 'title', 'author', 'replies'],
    func: async (page, kwargs) => {
        const limit = normalizeTiebaLimit(kwargs.limit);
        const payload = await fetchTiebaPagePc(page, kwargs, limit);
        const rawFeeds = Array.isArray(payload.page_data?.feed_list) ? payload.page_data.feed_list : [];
        const rawCards = buildTiebaPostCardsFromPagePc(rawFeeds);
        const items = buildTiebaPostItems(rawCards, limit);
        if (!items.length || payload.error_code) {
            throw new EmptyResultError('tieba posts', 'Tieba may have blocked the forum page, or the DOM structure may have changed');
        }
        return items;
    },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Verify the forum name/URL is correct and the forum still exists in a browser
  2. Inspect the fetched payload and update the page_data.feed_list / card-building logic in clis/tieba/posts.js if Tieba changed the contract
  3. Handle captcha/verification in the browser session, then retry
  4. Catch EmptyResultError and degrade gracefully (return []) in scripts that iterate many forums

Example fix

// before
const items = await tiebaPosts(page, { forum: kw });
// after
let items;
try {
  items = await tiebaPosts(page, { forum: kw });
} catch (e) {
  if (e instanceof EmptyResultError) items = [];
  else throw e;
}
Defensive patterns

Strategy: try-catch

Validate before calling

// check forum exists before scraping
const probe = await page.goto('https://tieba.baidu.com/f?kw=' + encodeURIComponent(kw));
if (!page.url().includes('/f?kw=')) throw new Error('Forum missing or redirected: ' + kw);

Type guard

function forumPayloadLooksValid(payload) {
  return payload && !payload.error_code && Array.isArray(payload.page_data?.feed_list);
}

Try / catch

try {
  const posts = await tiebaPosts(page, { forum: kw, limit });
} catch (e) {
  if (e instanceof EmptyResultError) return { forum: kw, posts: [], note: 'blocked/empty' };
  throw e;
}

Prevention

When it happens

Trigger: fetchTiebaPagePc returns page_data.feed_list empty/non-array, or buildTiebaPostItems yields zero items, or payload.error_code is set (Tieba API-level error like blocked forum or deleted forum).

Common situations: Forum name typo'd (nonexistent forum); forum restricted/banned by Tieba; anti-bot interstitial instead of the PC page; feed_list field renamed after a Tieba update.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/2a7477d91a2262bd. Report an issue: GitHub.