Skip to content

feat:add xianyu#696

Open
BruceLoveDecimal wants to merge 4 commits intojackwener:mainfrom
BruceLoveDecimal:feat/xianyu_adapter
Open

feat:add xianyu#696
BruceLoveDecimal wants to merge 4 commits intojackwener:mainfrom
BruceLoveDecimal:feat/xianyu_adapter

Conversation

@BruceLoveDecimal
Copy link
Copy Markdown
Contributor

feat:add xianyu

Description

新增 xianyu 站点适配器,支持三个基础命令:

xianyu search:复用已登录的 Chrome 会话,进入闲鱼搜索页并提取商品列表,返回结果中包含 item_id
xianyu item <item_id>:根据商品 item_id 获取闲鱼商品详情,包括标题、价格、成色、品牌、地区、卖家等信息
xianyu chat <item_id> <user_id>:根据商品 item_id 和聊天对象 user_id 打开闲鱼聊一聊会话,并支持通过 --text 发送消息

Related issue:

Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • 🌐 New site adapter
  • 📝 Documentation
  • ♻️ Refactor
  • 🔧 CI / build / tooling

Checklist

  • I ran the checks relevant to this PR
  • I updated tests or docs if needed
  • I included output or screenshots when useful

刘启灏 added 2 commits April 2, 2026 20:59
feat:add xianyu

feat:add xianyu
Copy link
Copy Markdown
Contributor

@Astro-Han Astro-Han left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work adding the Xianyu adapter! A few things to address before merge:

Must fix

  1. Missing navigateBefore: false — All three commands do their own page.goto(), but strategy: COOKIE + domain means the framework auto-navigates to https://www.goofish.com first. This causes a redundant round-trip on every invocation. See boss/search.ts or doubao/*.ts for the pattern.

  2. Missing deliverablesdocs/adapters/index.md (add a row) and docs/.vitepress/config.mts (add sidebar entry) need to be updated per project convention.

  3. item_id not in search columns — The documented workflow is "search → get item_id → pass to item", but item_id is not in the columns array, so it's invisible in default table output.

  4. item.ts auth check is dead code — The SESSION_EXPIRED|FAIL_SYS check on result.error (line 105) can never match. If mtop.request rejects, page.evaluate() throws before reaching this check. If it resolves with an error, the error info lives in response.ret, not in the fields returned by the evaluate script. Fix: catch mtop errors inside the evaluate and return a structured { error: '...' }.

Suggestions

  1. chat.ts item_title always emptybuildExtractChatStateEvaluate() hardcodes item_title: '' even though itemCard is already selected. Either extract the title or remove it from columns.

  2. SelectorError misused for input validationnormalizeId / normalizeItemId throw SelectorError, whose message prefix is "Could not find element: item_id". A CliError('INVALID_ARGS', ...) would be more appropriate for numeric validation.

  3. README — The per-adapter example block after the site table has no precedent among 60+ adapters (examples belong in docs/adapters/browser/xianyu.md). Also, xianyu is placed at the top of the table rather than appended.

  4. Minor: normalizeId is duplicated across chat.ts and item.ts (candidate for a shared utils.ts); as any cast on line 96 of item.ts is unnecessary since result already types error?: string.

@BruceLoveDecimal
Copy link
Copy Markdown
Contributor Author

@Astro-Han 感谢review,按照建议修改了下

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants