{"record":{"id":"411ee8f71cd23869","repo":"xpzouying/xiaohongshu-mcp","slug":"w-411ee8","errorCode":null,"errorMessage":"未找到评论输入框，该帖子可能不支持评论或网页端不可访问: %w","messagePattern":"未找到评论输入框，该帖子可能不支持评论或网页端不可访问: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"xiaohongshu/comment_feed.go","lineNumber":44,"sourceCode":"\tpage := f.page.Timeout(60 * time.Second)\n\n\turl := makeFeedDetailURL(feedID, xsecToken)\n\tlogrus.Infof(\"打开 feed 详情页: %s\", url)\n\n\t// 导航到详情页\n\tpage.MustNavigate(url)\n\tpage.MustWaitDOMStable()\n\thumanize.Delay(ctx, humanize.AfterNavigate)\n\n\t// 检测页面是否可访问\n\tif err := checkPageAccessible(page); err != nil {\n\t\treturn err\n\t}\n\n\telem, err := page.Element(\"div.input-box div.content-edit span\")\n\tif err != nil {\n\t\tlogrus.Warnf(\"Failed to find comment input box: %v\", err)\n\t\treturn fmt.Errorf(\"未找到评论输入框，该帖子可能不支持评论或网页端不可访问: %w\", err)\n\t}\n\n\tif err := humanize.Click(elem); err != nil {\n\t\tlogrus.Warnf(\"Failed to click comment input box: %v\", err)\n\t\treturn fmt.Errorf(\"无法点击评论输入框: %w\", err)\n\t}\n\thumanize.Delay(ctx, humanize.AfterClick)\n\n\telem2, err := page.Element(\"div.input-box div.content-edit p.content-input\")\n\tif err != nil {\n\t\tlogrus.Warnf(\"Failed to find comment input field: %v\", err)\n\t\treturn fmt.Errorf(\"未找到评论输入区域: %w\", err)\n\t}\n\n\tif err := humanize.Type(ctx, elem2, content); err != nil {\n\t\tlogrus.Warnf(\"Failed to input comment content: %v\", err)\n\t\treturn fmt.Errorf(\"无法输入评论内容: %w\", err)\n\t}","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/xpzouying/xiaohongshu-mcp/blob/332d196854a9eac0d2b8c2c0e3d0cc43139d724c/xiaohongshu/comment_feed.go#L26-L62","documentation":"PostComment locates the comment input box on the post page via go-rod selector 'div.input-box div.content-edit span'. When page.Element cannot find it, the function fails with this wrapped error, warning that the post may not support comments or is not accessible via web.","triggerScenarios":"PostComment called with a feedID whose post has comments disabled/deleted, a non-existent or wrong feed URL, a page that requires login again, or a XHS DOM update changing the selector.","commonSituations":"Commenting on posts with comment restrictions (author-limited, banned topic); stale feedID from an old link; being logged out so the page renders a login wall instead of the comment box; site A/B tests renaming CSS classes.","solutions":["Verify the feedID/url opens a real, comment-enabled post in a browser","Re-login / refresh cookies so the page renders the authenticated comment UI","Print page HTML on failure and update the CSS selector if the site DOM changed","Check the post type: some posts (e.g. certain video or restricted posts) genuinely have no comment box"],"exampleFix":"// before\nresp, _ := svc.PostComment(ctx, \"stale-or-wrong-feed-id\", \"nice\")\n// after\nif !postSupportsComments(feedID) { return errors.New(\"post does not allow comments\") }\nresp, _ := svc.PostComment(ctx, feedID, \"nice\")","handlingStrategy":"try-catch","validationCode":"// 调用前确认帖子可访问且允许评论（浏览器或 API 侧校验 feed URL 有效性）\nif feedID == \"\" || !strings.HasPrefix(feedURL, \"https://www.xiaohongshu.com/\") {\n    return errors.New(\"无效的帖子链接\")\n}","typeGuard":"func isCommentablePage(selErr error) bool { return selErr != nil && strings.Contains(selErr.Error(), \"未找到评论输入框\") }","tryCatchPattern":"err := svc.PostComment(ctx, feedID, content)\nif err != nil && strings.Contains(err.Error(), \"未找到评论输入框\") {\n    // 帖子不支持评论或登录失效：不要盲目重试，先人工核查\n    log.Warnf(\"帖子 %s 不可评论: %v\", feedID, err)\n}","preventionTips":["只对确认开放评论的帖子调用 PostComment","保持会话有效，登录过期先重新登录","XHS 改版后及时比对 DOM 更新选择器"],"tags":["selector","dom","comment","xiaohongshu","go-rod"],"backgroundTag":"element-not-found","analyzedSha":"332d196854a9eac0d2b8c2c0e3d0cc43139d724c","analyzedAt":"2026-09-05T22:22:55.988Z","contentChangedAt":"2026-09-05T22:22:55.988Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}