jackwener/OpenCLI · error · EmptyResultError

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

Error message

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

What it means

`tieba search` navigates to the search URL, runs the extraction script, and builds result items. If zero items are extracted from the result page, it throws this EmptyResultError instead of returning an empty list, because a normal Tieba search results page always renders at least one result for a valid query. The throw distinguishes 'we got blocked or the DOM changed' from a legitimate empty search.

Source

Thrown at clis/tieba/search.js:105

    strategy: Strategy.COOKIE,
    browser: true,
    navigateBefore: false,
    args: [
        { name: 'keyword', positional: true, required: true, type: 'string', help: 'Search keyword' },
        // Restrict unsupported pages before the browser session starts.
        { name: 'page', type: 'int', default: 1, choices: ['1'], help: 'Page number (currently only 1 is supported)' },
        { name: 'limit', type: 'int', default: 20, help: 'Number of items to return' },
    ],
    columns: ['rank', 'id', 'title', 'forum', 'author', 'time', 'url'],
    func: async (page, kwargs) => {
        assertSupportedPage(kwargs);
        const limit = normalizeTiebaLimit(kwargs.limit);
        // Use the default browser settle path so we do not read a stale page.
        await page.goto(getSearchUrl(kwargs));
        const raw = await page.evaluate(buildExtractSearchResultsEvaluate(limit));
        const items = buildTiebaSearchItems(Array.isArray(raw) ? raw : [], limit);
        if (!items.length) {
            throw new EmptyResultError('tieba search', 'Tieba may have blocked the result page, or the DOM structure may have changed');
        }
        return items;
    },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Reduce search frequency / add delays between calls and retry — transient rate-limit walls are the most common cause.
  2. Use a logged-in, cookie-persisted browser profile; anonymous searches are blocked more aggressively.
  3. Verify the query manually at the Tieba search URL in the same browser session and complete any captcha shown.
  4. If the page renders results manually but extraction still fails, update the library — the search-result selectors are outdated.
Defensive patterns

Strategy: retry

Try / catch

try {
  return await cli.search({ query });
} catch (e) {
  if (e instanceof EmptyResultError) {
    await sleep(randomInt(2000, 6000)); // anti-bot backoff
    return cli.search({ query });
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling `tieba search --query <q>` when the extraction finds no result nodes: an anti-bot/captcha wall replaced the results under the same URL, the query returns results only after login, or Tieba changed the search-results markup so selectors no longer match.

Common situations: Baidu rate-limiting a burst of searches from one IP; headless-browser detection; searching niche/rare terms while logged out; Tieba frontend redesign; stale cookies triggering a verification page.

Related errors


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