jackwener/OpenCLI · error · EmptyResultError

未抓取到创作者后台文章 (page=${articlePage})。可能页面尚未完成渲染或无文章。

Error message

未抓取到创作者后台文章 (page=${articlePage})。可能页面尚未完成渲染或无文章。

What it means

EmptyResultError thrown when the Toutiao creator dashboard content-management page loaded and was NOT detected as an auth wall, but parseToutiaoArticlesText() extracted zero article rows from the rendered page text. The library raises instead of returning [] so callers can distinguish 'no articles' from 'scrape failed'.

Source

Thrown at clis/toutiao/articles.js:42

        try {
            await page.goto(`https://mp.toutiao.com/profile_v4/manage/content/all?page=${articlePage}`);
            await page.wait('networkidle');
            await page.wait(3);
            text = await page.evaluate(`
(async () => {
    await new Promise(r => setTimeout(r, 2000));
    return document.body.innerText || '';
})()
`);
        } catch (error) {
            throw new CommandExecutionError(`toutiao articles render failed: ${error?.message || error}`);
        }
        if (looksToutiaoAuthWallText(text)) {
            throw new AuthRequiredError('mp.toutiao.com', 'Toutiao creator articles require a logged-in mp.toutiao.com browser session');
        }
        const rows = parseToutiaoArticlesText(text);
        if (rows.length === 0) {
            throw new EmptyResultError(
                'toutiao articles',
                `未抓取到创作者后台文章 (page=${articlePage})。可能页面尚未完成渲染或无文章。`,
            );
        }
        return rows;
    },
});

export { parseToutiaoArticlesText };
export const __test__ = {
    parseToutiaoArticlesText,
    parseArticlesPage,
};

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Re-run the command — slow rendering is the most common cause; retry after a few seconds or on a faster connection.
  2. Try page=1 first; if page=1 also fails the account likely has no articles or the session is stale (run toutiao auth verify).
  3. Log in at https://mp.toutiao.com/profile_v4/manage/content/all in the same browser profile and confirm the article table renders with data.
  4. If the table renders for a human but parsing still fails, update parseToutiaoArticlesText in clis/toutiao/utils.js to match the changed layout.
  5. Increase the wait budget (page.wait(3) and the in-page 2000ms delay) in clis/toutiao/articles.js on slow networks.

Example fix

// before
const rows = parseToutiaoArticlesText(text);
if (rows.length === 0) {
  throw new EmptyResultError('toutiao articles', `未抓取到创作者后台文章 (page=${articlePage})...`);
}
// after: one retry in case rendering was slow
let rows = parseToutiaoArticlesText(text);
if (rows.length === 0) {
  await page.reload();
  await page.wait(5);
  rows = parseToutiaoArticlesText(await page.evaluate('document.body.innerText'));
}
if (rows.length === 0) {
  throw new EmptyResultError('toutiao articles', `未抓取到创作者后台文章 (page=${articlePage})...`);
}
Defensive patterns

Strategy: retry

Validate before calling

// Preflight: confirm the session is live so a soft auth wall doesn't masquerade as empty
const cookies = await page.getCookies({ url: 'https://mp.toutiao.com' });
if (!cookies.some(c => c.name === 'sessionid' && c.value)) {
  throw new Error('Login to mp.toutiao.com before fetching articles');
}
const requestedPage = Number(kwargs.page ?? 1);
if (!Number.isInteger(requestedPage) || requestedPage < 1 || requestedPage > 4) {
  throw new Error('page must be an integer 1-4');
}

Type guard

function hasToutiaoArticleRows(value) {
  return Array.isArray(value) && value.length > 0 &&
    value.every(r => r && typeof r.title === 'string' && r.title.length > 0);
}

Try / catch

try {
  const rows = await toutiaoArticles({ page: 1 });
} catch (err) {
  if (err.name === 'EmptyResultError') {
    const retry = await toutiaoArticles({ page: 1 }).catch(() => []); // one retry for slow render
    console.warn('No toutiao articles (or page failed to render):', retry.length);
  } else if (err.name === 'AuthRequiredError') {
    console.error('Session expired — re-run login flow');
  } else {
    throw err;
  }
}

Prevention

When it happens

Trigger: Calling the `toutiao articles` CLI command (page 1-4) when the document body text of https://mp.toutiao.com/profile_v4/manage/content/all?page=N contains no rows the parser recognizes: the table has not finished rendering after networkidle + page.wait(3) + the in-page 2000ms delay, the requested page exceeds available content, the account has zero articles, or a Toutiao layout change broke parseToutiaoArticlesText.

Common situations: Slow network leaving the article table unrendered when the fixed waits elapse; querying page 2-4 on an account with fewer than a full page of articles; brand-new creator account with nothing published; site redesign changing table markup/text so the parser matches nothing.

Understand the failure class

Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.

Related errors


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