DIYgod/RSSHub · error · Error

No search results found. The page structure may have changed

Error message

No search results found. The page structure may have changed.

What it means

The Tieba search route loads /f/search/res and selects '.thread-content-box' after waiting for that selector (3s timeout). If the selector matches nothing it throws, meaning either the page never rendered the results (timeout/anti-bot) or Baidu renamed the result container.

Source

Thrown at lib/routes/baidu/tieba/search.tsx:62

    const qw = ctx.req.param('qw');

    const query = new URLSearchParams(ctx.req.param('routeParams'));
    query.set('ie', 'utf-8');
    query.set('qw', qw);
    query.set('rn', query.get('rn') || '20');
    const link = `https://tieba.baidu.com/f/search/res?${query.toString()}`;

    const html = await getTiebaPageContent(link, `tieba:search:${qw}:${query.toString()}`, {
        waitForSelector: '.thread-content-box',
        timeout: 3000,
    });

    const $ = load(html);

    const resultList = $('.thread-content-box');

    if (resultList.length === 0) {
        throw new Error('No search results found. The page structure may have changed.');
    }

    return {
        title: `${qw} - ${query.get('kw') || '百度贴'}吧搜索`,
        link,
        item: resultList.toArray().map((element) => {
            const item = $(element);

            // 标题
            const title = item.find('.title-content-wrap .title-wrap span').text().trim();

            // 内容摘要
            const details = item.find('.abstract-wrap span').text().trim();

            // 从链接中提取帖子URL,并规范化为绝对地址
            const linkPath = item.find('.action-bar-warp a.action-link-bg').attr('href') || '';
            const linkHref = normalizeUrl(linkPath);

View on GitHub (pinned to bed535e087)

Solutions

  1. Increase the waitForSelector timeout (lib/routes/baidu/tieba/search.tsx:58) if render is slow.
  2. Refresh BAIDU_COOKIE if the page is being redirected to a login/captcha.
  3. Confirm in a browser that the search query returns results; if Baidu renamed the class, update the selector.

Example fix

// before
waitForSelector: '.thread-content-box', timeout: 3000,
// after
waitForSelector: '.thread-content-box', timeout: 8000,
Defensive patterns

Strategy: retry

Validate before calling

const MIN_TIMEOUT_MS = 5000;
function timeoutIsSane(ms: number): boolean { return ms >= MIN_TIMEOUT_MS; }

Type guard

const pageHasResults = ($: ReturnType<typeof load>): boolean =>
  $('.thread-content-box').length > 0;

Try / catch

try {
  return await handler(ctx);
} catch (e) {
  if (e instanceof Error && /No search results found/.test(e.message)) {
    // bump waitForSelector timeout and retry once
    return await handler({ ...ctx, _timeout: 8000 });
  }
  throw e;
}

Prevention

When it happens

Trigger: getTiebaPageContent returns HTML with zero '.thread-content-box' elements - either because waitForSelector timed out at 3000ms before the Vue-rendered results appeared, or the search genuinely had no results, or an anti-bot page was served.

Common situations: Slow connection/JS render exceeding the 3s timeout; BAIDU_COOKIE issues returning a non-result page; Baidu renaming the '.thread-content-box' class; a query that legitimately has zero matches.

Related errors


AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12). Data as JSON: /api/errors/369dbd4faa08dd6b. Report an issue: GitHub.