xpzouying/xiaohongshu-mcp · error
未找到视频上传输入框
Error message
未找到视频上传输入框
What it means
uploadVideo 依次尝试 .upload-input 和 input[type='file'] 两个选择器均未找到文件上传输入框:发布页未切换到视频上传 Tab,或页面结构/加载状态异常导致输入框未渲染。
Source
Thrown at xiaohongshu/publish_video.go:88
return nil
}
// uploadVideo 上传单个本地视频
func uploadVideo(page *rod.Page, videoPath string) error {
pp := page.Timeout(5 * time.Minute) // 视频处理耗时更长
if _, err := os.Stat(videoPath); os.IsNotExist(err) {
return errors.Wrapf(err, "视频文件不存在: %s", videoPath)
}
// 寻找文件上传输入框(与图文一致的 class,或退回到 input[type=file])
var fileInput *rod.Element
var err error
fileInput, err = pp.Element(".upload-input")
if err != nil || fileInput == nil {
fileInput, err = pp.Element("input[type='file']")
if err != nil || fileInput == nil {
return errors.New("未找到视频上传输入框")
}
}
fileInput.MustSetFiles(videoPath)
// 对于视频,等待发布按钮变为可点击即表示处理完成
btn, err := waitForPublishButtonClickable(pp, 10*time.Minute)
if err != nil {
return err
}
slog.Info("视频上传/处理完成,发布按钮可点击", "btn", btn)
return nil
}
// submitPublishVideo 填写标题、正文、标签并点击发布(等待按钮可点击后再提交)
func submitPublishVideo(ctx context.Context, page *rod.Page, title, content string, tags []string, scheduleTime *time.Time, visibility string, products []string) error {
// 标题
titleElem, err := page.Element("div.d-input input")View on GitHub (pinned to 332d196854)
Solutions
- 截图/打印 page HTML 确认当前页面是否为发布页且含 file input
- 更新 uploadVideo 中的选择器列表以匹配最新 DOM
- 在上传前先等待关键元素(如发布表单)出现再查找输入框
- 确认登录态与账号可正常进入视频发布页
Example fix
// before
fileInput, err = pp.Element("input[type='file']")
if err != nil || fileInput == nil {
return errors.New("未找到视频上传输入框")
}
// after
fileInput, err = pp.Element("input[type='file']")
if err != nil || fileInput == nil {
html, _ := pp.HTML()
return fmt.Errorf("未找到视频上传输入框, url=%s", pp.MustInfo().URL)
} Defensive patterns
Strategy: try-catch
Validate before calling
// 上传前确认当前页面为发布页
u := page.MustInfo().URL
if !strings.Contains(u, "publish") { return fmt.Errorf("当前不在发布页: %s", u) } Try / catch
if err := action.PublishVideo(ctx, content); err != nil {
if strings.Contains(err.Error(), "未找到视频上传输入框") {
page.MustScreenshot("upload-input-missing.png")
}
return err
} Prevention
- 定期核对发布页 DOM,及时更新 .upload-input / input[type='file'] 选择器
- 上传前等待页面关键元素加载完成
- 登录态失效时先重新登录再进入发布页
When it happens
Trigger: PublishVideo → uploadVideo:发布页未加载完成即查找输入框;小红书前端改版删除/重命名 .upload-input 且页面无其他 file input;被重定向到登录页;页面被风控拦截展示验证码。
Common situations: 平台 DOM 升级导致选择器失效;页面加载慢,Element 默认超时内未出现上传控件;账号状态异常跳转到非发布页。
Related errors
AI-assisted analysis of xpzouying/xiaohongshu-mcp@332d196854 (2026-09-05).
Data as JSON: /api/errors/fe70dd6bb8aa3b36.
Report an issue: GitHub.