fix: like button wait, Gemini AI comments, rate-limit detection#51
Open
yike5460 wants to merge 17 commits intoautoclaw-cc:mainfrom
Open
fix: like button wait, Gemini AI comments, rate-limit detection#51yike5460 wants to merge 17 commits intoautoclaw-cc:mainfrom
yike5460 wants to merge 17 commits intoautoclaw-cc:mainfrom
Conversation
- 全局规则:禁止 URL 直接跳转内容页,必须通过 UI 交互 - 新增 browse 命令:搜索框输入 → DOM 分析 → 按顺序浏览 → 截图 - search.py: 优先通过搜索框 UI 搜索,回退 URL 方式 - browse.py: 完整的人类化浏览模块(分析布局、按序浏览、提取详情、截图) - vnc_display.py: 虚拟显示管理(Xvnc + noVNC) - chrome_launcher.py: 支持虚拟显示自动检测、Linux 服务器参数 - SKILL.md: 新增反风控全局规则文档 - xhs-explore SKILL.md: 固化操作流程文档 - xhs-auth SKILL.md: VNC 虚拟显示文档
- browse.py: 新增 browse_keywords() 多关键词搜索+去重 - cli.py: browse 命令支持逗号分隔多关键词, --max-per-keyword 参数 - xhs-explore SKILL.md: 关键词智能泛化指导(必做步骤) - AI 在搜索前必须分析用户意图并生成 3-5 个泛化关键词 - 包含直接/场景/话术/标签/反面 5 类关键词策略 - 示例和执行方式文档
- browse.py: 新增 _is_card_relevant() + _filter_relevant_cards() - 卡片标题需包含至少一个筛选词才会被浏览 - 空标题放行(无法判断),无筛选词时不过滤 - cli.py: browse 命令新增 --filter 参数 - SKILL.md: 全局规则新增相关性预筛选要求 - xhs-explore SKILL.md: AI 必须同时生成搜索词和筛选词的详细指导 - 筛选词策略:核心概念词 + 动作情绪词 + 平台黑话 - 建议 10-25 个筛选词
之前失败原因: - like-active class 不代表已点赞(所有 engage bar 按钮默认有此 class) - 选择器命中了评论区的赞而非帖子主体的赞 修复: - 通过 SVG xlink:href 判断状态: #like → #liked (已赞), #collect → #collected (已藏) - 限定在 #noteContainer 内的 engage bar 查找按钮 - 幂等检查 + 点击后验证 + 自动重试 - 同逻辑适用于收藏功能 验证:帖子点赞 729 → 730,href #like → #liked
根因:之前 click_publish_button 只 sleep(3) 就返回, 然后 CLI 的 finally 立刻关闭 browser/page, 导致发布请求被中断,帖子进入草稿箱而非真正发布。 修复: - 轮询 URL 变化,等待跳转到 /publish/success(最多 15s) - 成功后再等 3s 确保服务端处理完成 - 超时时检查错误 toast 提示 - 无错误但超时则抛出 PublishError
- 新增 scripts/image_gen.py: generate_images() 统一接口 - 优先 Gemini 2.5 Flash Image (nano banana) - 回退 OpenAI gpt-image-1 - SKILL.md: 全局配图生成规则 - xhs-publish SKILL.md: 配图生成规范和使用示例 - 添加 google-genai SDK 依赖
- 模型从 gemini-2.5-flash-preview-image-generation 升级到 gemini-3-pro-image-preview - 更新所有 SKILL.md 文档引用 - 已验证 API 调用成功
- like_favorite.py: 添加 like_feed/unlike_feed/favorite_feed/unfavorite_feed 包装函数,支持通过 feed_id + xsec_token 导航到详情页再操作 - comment.py: 添加 _ensure_detail_loaded / _switch_to_detail_tab 辅助函数, 增强评论功能在 SPA 导航后的稳定性 - batch_like.py: 新增批量搜索+点赞脚本
- Search by keywords with relevance filtering - Auto-like posts in popup (no URL navigation, anti-detection) - AI-generated comments via GPT-4.1-mini (with template fallback) - Promo/organic comment ratio control (default 70/30) - Daily limit, circuit breaker (3 consecutive failures = 24h pause) - Active hours window (CST 8:00-20:00) - Random 3-8 min intervals between comments - Feed dedup to avoid re-commenting - Dry-run mode for testing⚠️ Full auto-comment carries account ban risk
Higher quality comment generation for more natural promotional content.
- Replace OpenAI GPT-4.1 with Claude Haiku 4.5 (us.anthropic.claude-haiku-4-5-20251001-v1:0) - Use AnthropicBedrock SDK (AWS IAM auth, no API key needed) - Fix prompt to prevent extra formatting in output
原代码使用 keyDown/keyUp 两段式CDP事件发送Enter键, 小红书Vue搜索组件无法识别,导致搜索不提交,页面停留在首页。 修复:使用 rawKeyDown + char + keyUp 三段式完整CDP键盘事件序列, 确保搜索正确触发。 测试结果:搜索'AI创业'从0/120相关变为20/24相关。
- Added timeout recommendation (--timeout-seconds 3600) to SKILL.md - Scripts need 50+ minutes for 5 keywords due to anti-detection delays - Default cron timeout was causing premature termination
- Added _screenshot_comment_proof() to capture noteContainer after comment - Screenshots saved to ~/.xhs/marketing/screenshots/ with timestamp+feedId - Added --remote-allow-origins=* to chrome_launcher for CDP access - Screenshot path included in result JSON for reporting
- chrome_launcher: proxy param + XHS_PROXY env var for Chrome --proxy-server - auto_marketing: --proxy CLI arg, sets XHS_PROXY before connect - restart_chrome: pass proxy through - SKILL.md: proxy configuration docs + residential proxy recommendations - SKILL.md: bump version hint
1. Wait for #noteContainer (up to 10s) after clicking a card before
calling like_feed_in_popup, preventing 'no noteContainer' errors.
2. Replace anthropic SDK with google-genai (already in deps) for AI
comment generation, using gemini-2.0-flash model.
3. Add rate-limit/风控 detection and proxy bridge support:
- New scripts/xhs/rate_limit.py detects captcha/rate-limit pages
- chrome_launcher.py gains proxy bridge management for auth proxies
- auto_marketing.py checks for rate limiting after search, exits
gracefully with actionable proxy configuration instructions
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
#noteContainerto load after clicking a card before callinglike_feed_in_popup(), preventing crashes from missing containeranthropicSDK (not installed) withgoogle-genai(already in deps), usinggemini-2.0-flashfor comment generationscripts/xhs/rate_limit.pydetects 风控/captcha pages after search; auto_marketing exits gracefully with proxy config instructions. Added proxy bridge management inchrome_launcher.pyfor auth proxies (no change to default behavior)Test plan
--dry-runto verify noteContainer wait loop worksGOOGLE_API_KEYset🤖 Generated with Claude Code