jackwener/OpenCLI · error · EmptyResultError

Tieba may have blocked the hot page, or the DOM structure ma

Error message

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

What it means

The tieba hot command extracts titles/links from the Baidu Tieba hot page DOM inside the browser. If zero items with titles are extracted, EmptyResultError('tieba hot', ...) is thrown — either the page was blocked (anti-bot/verify page) or Tieba's DOM changed so the selectors no longer match.

Source

Thrown at clis/tieba/hot.js:38

        const raw = await page.evaluate(`(() => {
      const items = document.querySelectorAll('li.topic-top-item');
      return Array.from(items).map((item) => {
        const titleEl = item.querySelector('a.topic-text');
        const numEl = item.querySelector('span.topic-num');
        const descEl = item.querySelector('p.topic-top-item-desc');
        const href = titleEl?.getAttribute('href') || '';

        return {
          title: titleEl?.textContent?.trim() || '',
          discussions: numEl?.textContent?.trim() || '',
          description: descEl?.textContent?.trim() || '',
          url: href.startsWith('http') ? href : 'https://tieba.baidu.com' + href,
        };
      }).filter((item) => item.title).slice(0, ${limit});
    })()`);
        const items = Array.isArray(raw) ? raw : [];
        if (!items.length) {
            throw new EmptyResultError('tieba hot', 'Tieba may have blocked the hot page, or the DOM structure may have changed');
        }
        return items.map((item, index) => ({
            rank: index + 1,
            title: item.title || '',
            discussions: item.discussions || '',
            description: item.description || '',
            url: item.url || '',
        }));
    },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Open the hot page in the controlled browser and inspect whether a verification interstitial is shown; solve it manually then retry
  2. Update the DOM selectors in clis/tieba/hot.js to match current markup after inspecting page.content()
  3. Slow down scrape frequency or rotate egress IP to avoid blocking
  4. Retry after a delay — blocks are often temporary
Defensive patterns

Strategy: try-catch

Validate before calling

const html = await page.content();
if (/verify|captcha|wappass/i.test(html)) throw new Error('Tieba verification interstitial — solve before scraping');

Type guard

function looksBlocked(html) {
  return /security\/verify|captcha|wappass|百度安全验证/i.test(html);
}

Try / catch

try {
  const hot = await tiebaHot(page, { limit });
} catch (e) {
  if (e instanceof EmptyResultError) {
    console.warn('Tieba hot blocked or markup changed; skipping');
    return [];
  }
  throw e;
}

Prevention

When it happens

Trigger: Running the tieba hot scrape when the in-page evaluate returns an empty array: page served is a security-verification interstitial, region-blocked page, or the hot-list container/selector markup changed.

Common situations: Baidu serving captcha/verify pages to datacenter IPs; frequent scraping triggering rate limits; Tieba front-end redesign moving the hot list selectors; mobile-vs-pc template mismatch.

Related errors


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