{"record":{"id":"128635200f60af4f","repo":"jackwener/OpenCLI","slug":"toutiao-creator-articles-require-a-logged-in-mp-to","errorCode":null,"errorMessage":"Toutiao creator articles require a logged-in mp.toutiao.com browser session","messagePattern":"Toutiao creator articles require a logged-in mp\\.toutiao\\.com browser session","errorType":"exception","errorClass":"AuthRequiredError","httpStatus":null,"severity":"error","filePath":"clis/toutiao/articles.js","lineNumber":38,"sourceCode":"    columns: ['title', 'date', 'status', '展现', '阅读', '点赞', '评论'],\n    func: async (page, kwargs) => {\n        const articlePage = parseArticlesPage(kwargs.page, 1);\n        let text;\n        try {\n            await page.goto(`https://mp.toutiao.com/profile_v4/manage/content/all?page=${articlePage}`);\n            await page.wait('networkidle');\n            await page.wait(3);\n            text = await page.evaluate(`\n(async () => {\n    await new Promise(r => setTimeout(r, 2000));\n    return document.body.innerText || '';\n})()\n`);\n        } catch (error) {\n            throw new CommandExecutionError(`toutiao articles render failed: ${error?.message || error}`);\n        }\n        if (looksToutiaoAuthWallText(text)) {\n            throw new AuthRequiredError('mp.toutiao.com', 'Toutiao creator articles require a logged-in mp.toutiao.com browser session');\n        }\n        const rows = parseToutiaoArticlesText(text);\n        if (rows.length === 0) {\n            throw new EmptyResultError(\n                'toutiao articles',\n                `未抓取到创作者后台文章 (page=${articlePage})。可能页面尚未完成渲染或无文章。`,\n            );\n        }\n        return rows;\n    },\n});\n\nexport { parseToutiaoArticlesText };\nexport const __test__ = {\n    parseToutiaoArticlesText,\n    parseArticlesPage,\n};\n","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/toutiao/articles.js#L20-L56","documentation":"After rendering the Toutiao creator articles page, looksToutiaoAuthWallText(text) detects login-wall copy in the extracted text and the command throws AuthRequiredError('mp.toutiao.com', 'Toutiao creator articles require a logged-in mp.toutiao.com browser session'). It distinguishes an auth wall from an empty result so the user knows to log in rather than debug parsing.","triggerScenarios":"The rendered page's innerText matched the toutiao auth-wall heuristics — mp.toutiao.com served its login prompt instead of the article list because no valid creator session exists.","commonSituations":"Browser profile not logged into mp.toutiao.com; Toutiao session cookie (tt_webid / sessionid) expired; QR-code re-login forced by Toutiao after risk-control checks; automated browser using a fresh profile each run.","solutions":["Log in to mp.toutiao.com in the automated browser profile (scan QR code) and rerun","Use a persistent user-data-dir so the creator session survives restarts","Refresh/replace expired session cookies for mp.toutiao.com","Confirm the page really shows the login wall (log the extracted text) to rule out false-positive text matching"],"exampleFix":"// before\nawait page.goto('https://mp.toutiao.com/...'); // logged-out profile\n// after\nawait context.storageState({ path: 'toutiao-state.json' }); // reuse saved session\nawait page.goto('https://mp.toutiao.com/...');","handlingStrategy":"validation","validationCode":"const text = await page.evaluate(() => document.body.innerText);\nif (/登录|扫码|login|scan qr/i.test(text) && !/文章|articles/i.test(text)) {\n  throw new Error('AUTH_REQUIRED: mp.toutiao.com login wall detected');\n}","typeGuard":"function isAuthWall(text) { return typeof text === 'string' && /登录|扫码登录|请登录/i.test(text); }","tryCatchPattern":"try { await fetchToutiaoArticles(); } catch (e) {\n  if (e instanceof AuthRequiredError) {\n    await openMpToutiaoLoginAndScanQr(); // manual one-time login\n    return fetchToutiaoArticles();\n  }\n  throw e;\n}","preventionTips":["Persist the mp.toutiao.com creator session in a stable profile","Re-scan QR login when risk control forces it","Check session cookies (sessionid) before runs","Log extracted text once to confirm auth-wall detection is accurate"],"tags":["auth","toutiao","session","login"],"backgroundTag":"auth-required-session-expired","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}