{"record":{"id":"2a7477d91a2262bd","repo":"jackwener/OpenCLI","slug":"tieba-may-have-blocked-the-forum-page-or-the-dom","errorCode":null,"errorMessage":"Tieba may have blocked the forum page, or the DOM structure may have changed","messagePattern":"Tieba may have blocked the forum page, or the DOM structure may have changed","errorType":"exception","errorClass":"EmptyResultError","httpStatus":null,"severity":"error","filePath":"clis/tieba/posts.js","lineNumber":82,"sourceCode":"    description: 'Browse posts in a tieba forum',\n    domain: 'tieba.baidu.com',\n    strategy: Strategy.COOKIE,\n    browser: true,\n    navigateBefore: false,\n    args: [\n        { name: 'forum', positional: true, required: true, type: 'string', help: 'Forum name in Chinese' },\n        { name: 'page', type: 'int', default: 1, help: 'Page number' },\n        { name: 'limit', type: 'int', default: 20, help: 'Number of items to return' },\n    ],\n    columns: ['rank', 'title', 'author', 'replies'],\n    func: async (page, kwargs) => {\n        const limit = normalizeTiebaLimit(kwargs.limit);\n        const payload = await fetchTiebaPagePc(page, kwargs, limit);\n        const rawFeeds = Array.isArray(payload.page_data?.feed_list) ? payload.page_data.feed_list : [];\n        const rawCards = buildTiebaPostCardsFromPagePc(rawFeeds);\n        const items = buildTiebaPostItems(rawCards, limit);\n        if (!items.length || payload.error_code) {\n            throw new EmptyResultError('tieba posts', 'Tieba may have blocked the forum page, or the DOM structure may have changed');\n        }\n        return items;\n    },\n});\n","sourceCodeStart":64,"sourceCodeEnd":87,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/tieba/posts.js#L64-L87","documentation":"The tieba posts command fetches the forum page (PC template), builds post cards from payload.page_data.feed_list, and throws EmptyResultError when no items were produced or the payload carries an error_code. This signals the forum page was blocked/empty or the data contract changed.","triggerScenarios":"fetchTiebaPagePc returns page_data.feed_list empty/non-array, or buildTiebaPostItems yields zero items, or payload.error_code is set (Tieba API-level error like blocked forum or deleted forum).","commonSituations":"Forum name typo'd (nonexistent forum); forum restricted/banned by Tieba; anti-bot interstitial instead of the PC page; feed_list field renamed after a Tieba update.","solutions":["Verify the forum name/URL is correct and the forum still exists in a browser","Inspect the fetched payload and update the page_data.feed_list / card-building logic in clis/tieba/posts.js if Tieba changed the contract","Handle captcha/verification in the browser session, then retry","Catch EmptyResultError and degrade gracefully (return []) in scripts that iterate many forums"],"exampleFix":"// before\nconst items = await tiebaPosts(page, { forum: kw });\n// after\nlet items;\ntry {\n  items = await tiebaPosts(page, { forum: kw });\n} catch (e) {\n  if (e instanceof EmptyResultError) items = [];\n  else throw e;\n}","handlingStrategy":"try-catch","validationCode":"// check forum exists before scraping\nconst probe = await page.goto('https://tieba.baidu.com/f?kw=' + encodeURIComponent(kw));\nif (!page.url().includes('/f?kw=')) throw new Error('Forum missing or redirected: ' + kw);","typeGuard":"function forumPayloadLooksValid(payload) {\n  return payload && !payload.error_code && Array.isArray(payload.page_data?.feed_list);\n}","tryCatchPattern":"try {\n  const posts = await tiebaPosts(page, { forum: kw, limit });\n} catch (e) {\n  if (e instanceof EmptyResultError) return { forum: kw, posts: [], note: 'blocked/empty' };\n  throw e;\n}","preventionTips":["Validate forum keywords exist before batch iteration","Handle error_code payloads explicitly (banned/deleted forums)","Keep a manual-verification step ready for Baidu anti-bot interstitials","Update feed_list extraction logic promptly after Tieba contract changes"],"tags":["scraping","tieba","empty-result","forum"],"backgroundTag":"dom-scrape-extraction-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}