xpzouying/xiaohongshu-mcp · error

评论未确认成功:提交后未在评论区出现(可能账号被限制或发送失败),feed: %s

Error message

评论未确认成功:提交后未在评论区出现(可能账号被限制或发送失败),feed: %s

What it means

PostComment verifies success by checking the comment actually renders in the comment list within 4 seconds (waitCommentRendered). If it never appears, the library refuses to report fake success and returns this error, noting the account may be limited or the send failed.

Source

Thrown at xiaohongshu/comment_feed.go:82

	humanize.Delay(ctx, humanize.AfterType)

	submitButton, err := page.Element("div.bottom button.submit")
	if err != nil {
		logrus.Warnf("Failed to find submit button: %v", err)
		return fmt.Errorf("未找到提交按钮: %w", err)
	}

	if err := humanize.Click(submitButton); err != nil {
		logrus.Warnf("Failed to click submit button: %v", err)
		return fmt.Errorf("无法点击提交按钮: %w", err)
	}

	humanize.Delay(ctx, humanize.AfterClick)

	// 就地校验:提交后评论应在评论区渲染出现;未出现则判定失败,避免假成功。
	if !waitCommentRendered(page, content, 4*time.Second) {
		logrus.Warnf("评论提交后未在评论区渲染,判定未成功: feed=%s", feedID)
		return fmt.Errorf("评论未确认成功:提交后未在评论区出现(可能账号被限制或发送失败),feed: %s", feedID)
	}

	logrus.Infof("Comment posted and verified to feed: %s", feedID)
	return nil
}

// commentRendered 就地读当前页评论区 DOM,判断指定文本的评论是否已渲染出现。
// 不重新导航、不滚动——只读已加载的 .comments-container 的可见文本。
func commentRendered(page *rod.Page, content string) bool {
	res, err := page.Eval(`(txt) => {
		const c = document.querySelector('.comments-container');
		return c ? c.innerText.includes(txt) : false;
	}`, content)
	if err != nil {
		return false
	}
	return res.Value.Bool()
}

View on GitHub (pinned to 332d196854)

Solutions

  1. Reduce comment frequency and let the account cool down (risk control)
  2. Remove links/sensitive words from the comment content and retry
  3. Re-login to refresh the session, then verify commenting works manually in a browser
  4. Increase the verification wait if pages load slowly (library-level change to waitCommentRendered timeout)

Example fix

// before
count := 0
for { _ = svc.PostComment(ctx, feed, "看这里 http://spam.example") ; count++ } // triggers filtering
// after
if rateLimitedRecently() { return errors.New("cooling down") }
_ = svc.PostComment(ctx, feed, "写得真好,学习了") // clean content, throttled
Defensive patterns

Strategy: try-catch

Validate before calling

// 提交前自查内容风控风险
if strings.ContainsAny(content, "http:/") || utf8.RuneCountInString(content) < 2 {
    return errors.New("评论含链接或过短,易被过滤")
}

Try / catch

err := svc.PostComment(ctx, feedID, content)
if err != nil && strings.Contains(err.Error(), "评论未确认成功") {
    // 不要立即重试:先降频、换内容,或检查账号状态
    log.Warnf("评论可能被风控过滤: %v", err)
    time.Sleep(10 * time.Minute)
}

Prevention

When it happens

Trigger: Submit click succeeded mechanically but the comment was silently rejected: account shadow-banned/rate-limited, comment blocked by sensitive-word filtering, login expired so the action was discarded, or the 4s render window was too short on a slow page.

Common situations: Accounts under risk control after high-frequency commenting; comments containing links or flagged keywords filtered by XHS; expired session where clicks do nothing; heavy network latency exceeding the 4s verification window.

Related errors


AI-assisted analysis of xpzouying/xiaohongshu-mcp@332d196854 (2026-09-05). Data as JSON: /api/errors/fb1bd603b2c7d63f. Report an issue: GitHub.