jackwener/OpenCLI · error · EmptyResultError

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

Error message

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

What it means

After `tieba read` asserts it is on the correct thread page, it extracts posts/comments via `buildTiebaReadItems`. If the extraction yields zero items while the page URL was correct, the library throws this EmptyResultError rather than returning an empty array, because a rendered Tieba thread page should always contain at least the main post. This signals either a block/challenge page or a DOM structure change that broke the selectors.

Source

Thrown at clis/tieba/read.js:137

    navigateBefore: false,
    args: [
        { name: 'id', positional: true, required: true, type: 'string', help: 'Thread ID' },
        { name: 'page', type: 'int', default: 1, help: 'Page number' },
        { name: 'limit', type: 'int', default: 30, help: 'Number of replies to return' },
    ],
    columns: ['floor', 'author', 'content', 'time'],
    func: async (page, kwargs) => {
        const pageNumber = Math.max(1, Number(kwargs.page || 1));
        // Use the browser's normal settle path so we do not scrape stale DOM from the previous tab state.
        await page.goto(getThreadUrl(kwargs));
        const raw = (await page.evaluate(buildExtractReadEvaluate()) || {});
        assertTiebaReadTargetPage(raw, kwargs);
        const items = buildTiebaReadItems(raw, {
            limit: kwargs.limit,
            includeMainPost: pageNumber === 1,
        });
        if (!items.length) {
            throw new EmptyResultError('tieba read', 'Tieba may have blocked the thread page, or the DOM structure may have changed');
        }
        return items;
    },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Re-run with a logged-in, cookie-persisted browser profile — anonymous/headless requests are the most commonly blocked.
  2. Switch to a residential IP or wait out a temporary Baidu rate-limit block, then retry.
  3. Open the thread URL manually in the same browser session to confirm whether a captcha/verification page is shown, and complete it.
  4. If the page renders fine manually, the selectors are outdated — update the library to match the new Tieba DOM.
Defensive patterns

Strategy: retry

Validate before calling

// quick reachability/auth sanity check before scraping
const res = await fetch(`https://tieba.baidu.com/p/${threadId}`, { method: 'HEAD' });
if (res.status === 404) throw new Error('thread does not exist');

Try / catch

try {
  return await cli.read({ id: threadId, page });
} catch (e) {
  if (e instanceof EmptyResultError) {
    await backoff(delay);            // likely a block wall
    return cli.read({ id: threadId, page }); // retry, ideally logged-in profile
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling `tieba read` (single fetch or streaming run in the cli() handler) when the page content has no extractable thread items: Tieba served an anti-bot/verification wall at the correct URL, the thread content is behind a login, or Tieba changed its markup so the extraction script finds no posts.

Common situations: Datacenter IP flagged by Baidu leading to a soft-block with the URL unchanged; headless browser fingerprint detected; Tieba frontend redesign breaking data-e2e/class selectors; region-restricted content.

Related errors


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