{"record":{"id":"7c73334b782388db","repo":"DIYgod/RSSHub","slug":"no-user-posts-found-the-page-structure-may-have-c","errorCode":null,"errorMessage":"No user posts found. The page structure may have changed or the user does not exist.","messagePattern":"No user posts found\\. The page structure may have changed or the user does not exist\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"lib/routes/baidu/tieba/user.tsx","lineNumber":51,"sourceCode":"};\n\nasync function handler(ctx) {\n    const uid = ctx.req.param('uid');\n    const encodedUid = encodeURIComponent(uid);\n    const url = `https://tieba.baidu.com/home/main?un=${encodedUid}`;\n\n    const html = await getTiebaPageContent(url, `tieba:user:${uid}`, {\n        waitForSelector: '.thread-card',\n        timeout: 3000,\n    });\n\n    const $ = load(html);\n\n    const name = $('span.userinfo_username').text() || uid;\n    const list = $('.thread-card');\n\n    if (list.length === 0) {\n        throw new Error('No user posts found. The page structure may have changed or the user does not exist.');\n    }\n\n    return {\n        title: `${name} 的贴吧`,\n        link: `https://tieba.baidu.com/home/main?un=${encodedUid}`,\n        item: list.toArray().map((element) => {\n            const item = $(element);\n\n            // 作者\n            const authorName = item.find('.head-name').text().trim() || name;\n\n            // 标题\n            const title = item.find('.title-text').text().trim();\n\n            // 内容\n            const content = item.find('.tb-richtext .text').text().trim();\n\n            // 图片","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/baidu/tieba/user.tsx#L33-L69","documentation":"The Tieba user route loads a user's profile page, waits for '.thread-card', then counts matches. If zero, it throws, indicating the user does not exist, has no posts, the page was served as an anti-bot interstitial, or the '.thread-card' class was renamed.","triggerScenarios":"getTiebaPageContent returns HTML where '.thread-card' matches nothing - invalid uid, a user with zero posts, an unauthenticated page that lacks the card list, or a Baidu markup change.","commonSituations":"Wrong/typo uid; BAIDU_COOKIE missing so the profile page renders differently; Baidu A/B test renaming 'thread-card'; the user was deleted/banned.","solutions":["Verify the uid by opening https://tieba.baidu.com/home/main?un=<uid> in a browser.","Refresh BAIDU_COOKIE so the profile page renders the full thread list.","If Baidu renamed the class, update the selector at lib/routes/baidu/tieba/user.tsx:49."],"exampleFix":"// before\nconst list = $('.thread-card');\n// after (renamed class)\nconst list = $('.user-thread-item');","handlingStrategy":"validation","validationCode":"function userHasPosts($: ReturnType<typeof load>): boolean {\n  return $('.thread-card').length > 0 || $('span.userinfo_username').length > 0;\n}","typeGuard":"const userPageLooksReal = ($: ReturnType<typeof load>): boolean =>\n  $('span.userinfo_username').length > 0;","tryCatchPattern":"try {\n  return await handler(ctx);\n} catch (e) {\n  if (e instanceof Error && /No user posts found/.test(e.message)) {\n    ctx.throw(404, 'User not found or cookie invalid');\n  }\n  throw e;\n}","preventionTips":["Validate the uid resolves to a real profile page before rendering.","Keep BAIDU_COOKIE fresh so the profile renders the full thread list.","Pin a fixture of a real profile HTML in tests to catch selector drift."],"tags":["baidu-tieba","scraping","cookie","css-selector","rss-route"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}