goofish-cli 0.6.3__tar.gz → 0.6.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/.claude-plugin/marketplace.json +1 -1
  2. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/CHANGELOG.md +14 -0
  3. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/PKG-INFO +2 -2
  4. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/README.md +1 -1
  5. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/pyproject.toml +1 -1
  6. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/skills/goofish-publish-item/SKILL.md +1 -1
  7. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/skills/goofish-publish-item/references/category-selection.md +2 -2
  8. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/src/goofish_cli/commands/category/recommend.py +37 -21
  9. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/src/goofish_cli/commands/item/publish.py +4 -3
  10. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/src/goofish_cli/core/qr_login.py +9 -3
  11. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/.gitignore +0 -0
  12. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/LICENSE +0 -0
  13. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/NOTICE +0 -0
  14. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/examples/README.md +0 -0
  15. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/skills/goofish-overview/SKILL.md +0 -0
  16. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/skills/goofish-overview/references/accounts.md +0 -0
  17. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/skills/goofish-overview/references/mcp-tools-index.md +0 -0
  18. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/skills/goofish-overview/references/xianyu-concepts.md +0 -0
  19. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/skills/goofish-publish-item/references/common-pitfalls.md +0 -0
  20. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/skills/goofish-publish-item/references/image-checklist.md +0 -0
  21. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/skills/goofish-publish-item/references/title-formula.md +0 -0
  22. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/skills/goofish-reply-buyer/SKILL.md +0 -0
  23. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/skills/goofish-reply-buyer/references/bargain-ladder.md +0 -0
  24. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/skills/goofish-reply-buyer/references/intent-classification.md +0 -0
  25. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/skills/goofish-reply-buyer/references/tone-guide.md +0 -0
  26. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/skills/goofish-risk-guard/SKILL.md +0 -0
  27. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/skills/goofish-risk-guard/references/external-contact-keywords.md +0 -0
  28. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/skills/goofish-risk-guard/references/forbidden-words.md +0 -0
  29. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/skills/goofish-risk-guard/references/publish-red-lines.md +0 -0
  30. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/skills/goofish-risk-guard/references/x5sec-recovery.md +0 -0
  31. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/skills/goofish-shop-diagnosis/SKILL.md +0 -0
  32. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/skills/goofish-shop-diagnosis/references/diagnosis-workflow.md +0 -0
  33. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/skills/goofish-shop-diagnosis/references/rank-factors.md +0 -0
  34. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/skills/goofish-shop-diagnosis/references/traffic-drop-causes.md +0 -0
  35. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/src/goofish_cli/__init__.py +0 -0
  36. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/src/goofish_cli/cli.py +0 -0
  37. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/src/goofish_cli/commands/__init__.py +0 -0
  38. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/src/goofish_cli/commands/auth/__init__.py +0 -0
  39. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/src/goofish_cli/commands/auth/login.py +0 -0
  40. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/src/goofish_cli/commands/auth/reset_guard.py +0 -0
  41. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/src/goofish_cli/commands/auth/status.py +0 -0
  42. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/src/goofish_cli/commands/category/__init__.py +0 -0
  43. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/src/goofish_cli/commands/item/__init__.py +0 -0
  44. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/src/goofish_cli/commands/item/delete.py +0 -0
  45. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/src/goofish_cli/commands/item/get.py +0 -0
  46. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/src/goofish_cli/commands/item/list.py +0 -0
  47. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/src/goofish_cli/commands/item/view.py +0 -0
  48. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/src/goofish_cli/commands/location/__init__.py +0 -0
  49. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/src/goofish_cli/commands/location/default.py +0 -0
  50. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/src/goofish_cli/commands/media/__init__.py +0 -0
  51. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/src/goofish_cli/commands/media/upload.py +0 -0
  52. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/src/goofish_cli/commands/message/__init__.py +0 -0
  53. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/src/goofish_cli/commands/message/history.py +0 -0
  54. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/src/goofish_cli/commands/message/list_chats.py +0 -0
  55. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/src/goofish_cli/commands/message/send.py +0 -0
  56. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/src/goofish_cli/commands/message/watch.py +0 -0
  57. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/src/goofish_cli/commands/search/__init__.py +0 -0
  58. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/src/goofish_cli/commands/search/search.py +0 -0
  59. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/src/goofish_cli/commands/skills/__init__.py +0 -0
  60. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/src/goofish_cli/commands/skills/install.py +0 -0
  61. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/src/goofish_cli/core/__init__.py +0 -0
  62. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/src/goofish_cli/core/browser.py +0 -0
  63. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/src/goofish_cli/core/browser_cookie.py +0 -0
  64. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/src/goofish_cli/core/cookie_types.py +0 -0
  65. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/src/goofish_cli/core/crypto.py +0 -0
  66. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/src/goofish_cli/core/errors.py +0 -0
  67. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/src/goofish_cli/core/guard.py +0 -0
  68. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/src/goofish_cli/core/item_data.py +0 -0
  69. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/src/goofish_cli/core/item_page.py +0 -0
  70. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/src/goofish_cli/core/limiter.py +0 -0
  71. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/src/goofish_cli/core/local_state.py +0 -0
  72. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/src/goofish_cli/core/message_history.py +0 -0
  73. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/src/goofish_cli/core/mtop.py +0 -0
  74. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/src/goofish_cli/core/output.py +0 -0
  75. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/src/goofish_cli/core/refresh.py +0 -0
  76. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/src/goofish_cli/core/registry.py +0 -0
  77. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/src/goofish_cli/core/sandbox_browser.py +0 -0
  78. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/src/goofish_cli/core/search_data.py +0 -0
  79. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/src/goofish_cli/core/session.py +0 -0
  80. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/src/goofish_cli/core/sign.py +0 -0
  81. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/src/goofish_cli/core/strategy.py +0 -0
  82. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/src/goofish_cli/core/token.py +0 -0
  83. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/src/goofish_cli/core/write_operation.py +0 -0
  84. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/src/goofish_cli/core/ws.py +0 -0
  85. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/src/goofish_cli/mcp_server.py +0 -0
  86. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/src/goofish_cli/sandbox/__init__.py +0 -0
  87. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/src/goofish_cli/sandbox/assets/Dockerfile +0 -0
  88. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/src/goofish_cli/sandbox/assets/entrypoint.sh +0 -0
  89. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/src/goofish_cli/sandbox/cli.py +0 -0
  90. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/src/goofish_cli/sandbox/interactive.py +0 -0
  91. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/src/goofish_cli/sandbox/runtime.py +0 -0
  92. {goofish_cli-0.6.3 → goofish_cli-0.6.5}/src/goofish_cli/static/goofish_js_version_2.js +0 -0
@@ -3,7 +3,7 @@
3
3
  "name": "goofish-cli-skills",
4
4
  "displayName": "goofish-cli Skills",
5
5
  "description": "闲鱼(goofish.com)自动化运营的 Claude Skills 套件。配合 goofish-cli MCP server 使用,让 Agent 在发布商品 / 回复买家 / 风控预检 / 店铺诊断这些场景里上手即会。",
6
- "version": "0.6.3",
6
+ "version": "0.6.5",
7
7
  "author": {
8
8
  "name": "fancy",
9
9
  "url": "https://github.com/fancyboi999"
@@ -4,6 +4,20 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
5
5
  and this project adheres to [Semantic Versioning](https://semver.org/).
6
6
 
7
+ ## [0.6.5](https://github.com/fancyboi999/goofish-cli/compare/v0.6.4...v0.6.5) (2026-11-18)
8
+
9
+
10
+ ### Bug Fixes
11
+
12
+ * **category:** allow virtual categories without a Taobao category id ([#62](https://github.com/fancyboi999/goofish-cli/issues/62)) ([7e6a155](https://github.com/fancyboi999/goofish-cli/commit/7e6a1552759d2d0441426c7c72741cc36efcb1d8))
13
+
14
+ ## [0.6.4](https://github.com/fancyboi999/goofish-cli/compare/v0.6.3...v0.6.4) (2026-11-14)
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * allow slower QR login page loading ([#57](https://github.com/fancyboi999/goofish-cli/issues/57)) ([f653453](https://github.com/fancyboi999/goofish-cli/commit/f6534538e4826d58295e2ec94a4a75f9f21227b0))
20
+
7
21
  ## [0.6.3](https://github.com/fancyboi999/goofish-cli/compare/v0.6.2...v0.6.3) (2026-10-26)
8
22
 
9
23
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: goofish-cli
3
- Version: 0.6.3
3
+ Version: 0.6.5
4
4
  Summary: 闲鱼 CLI — 支持 MCP,未来支持 Claude Skills。为 AI Agent 提供闲鱼自动化基础能力。
5
5
  Project-URL: Homepage, https://github.com/fancyboi999/goofish-cli
6
6
  Project-URL: Repository, https://github.com/fancyboi999/goofish-cli
@@ -203,7 +203,7 @@ OpenClaw `2026.6.1` 及以上可把本仓库作为 compatible bundle 加载。
203
203
  openclaw plugins install clawhub:openclaw-goofish
204
204
 
205
205
  # 登录态由用户在终端初始化,不交给 Agent 覆盖
206
- uvx --from goofish-cli==0.6.3 goofish auth login --qr
206
+ uvx --from goofish-cli==0.6.5 goofish auth login --qr
207
207
 
208
208
  openclaw plugins inspect goofish --json
209
209
  openclaw gateway restart
@@ -162,7 +162,7 @@ OpenClaw `2026.6.1` 及以上可把本仓库作为 compatible bundle 加载。
162
162
  openclaw plugins install clawhub:openclaw-goofish
163
163
 
164
164
  # 登录态由用户在终端初始化,不交给 Agent 覆盖
165
- uvx --from goofish-cli==0.6.3 goofish auth login --qr
165
+ uvx --from goofish-cli==0.6.5 goofish auth login --qr
166
166
 
167
167
  openclaw plugins inspect goofish --json
168
168
  openclaw gateway restart
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "goofish-cli"
7
- version = "0.6.3"
7
+ version = "0.6.5"
8
8
  description = "闲鱼 CLI — 支持 MCP,未来支持 Claude Skills。为 AI Agent 提供闲鱼自动化基础能力。"
9
9
  readme = "README.md"
10
10
  license = { text = "Apache-2.0" }
@@ -136,7 +136,7 @@ for image in 本地图片路径:
136
136
  )
137
137
  ```
138
138
 
139
- 发布也可用 `images=[本地路径, ...]` 自动上传,不能把 CDN URL 当本地路径。已提前上传时复用 `images_json`,避免重复上传。类目 DTO 必须包含 cat_id/cat_name/channel_cat_id/tb_cat_id,地址采用 selected 字段。缺少身份的类目不能猜补。模型分数不是校准概率,未知值为 null。
139
+ 发布也可用 `images=[本地路径, ...]` 自动上传,不能把 CDN URL 当本地路径。已提前上传时复用 `images_json`,避免重复上传。类目 DTO 必须包含 cat_id/cat_name/channel_cat_id;虚拟/服务类目的 tb_cat_id 可为空字符串,地址采用 selected 字段。缺少身份的类目不能猜补。模型分数不是校准概率,未知值为 null。
140
140
 
141
141
  成功返回 accepted 与 item_id 后,用 item_get 回读确认。失败返回的 images/category/location 可复用;submission_unknown 必须先核对自己的商品列表,禁止盲目重试。发布和下架共用 item.write 默认 1 次/分钟,上传独立 media.write 默认 9 次/分钟。
142
142
 
@@ -13,7 +13,7 @@ category_recommend(
13
13
  )
14
14
  ```
15
15
 
16
- 返回 `{cat_id, cat_name, channel_cat_id, tb_cat_id, confidence, confidence_source}`。confidence 为模型分数,不是校准概率;缺失为 null。
16
+ 返回 `{cat_id, cat_name, channel_cat_id, tb_cat_id, confidence, confidence_source}`。虚拟/服务类目(如「电子资料」)没有淘宝类目,tb_cat_id 为空字符串,网页端发布时也以空值提交。confidence 为模型分数,不是校准概率;缺失为 null。
17
17
 
18
18
  ## 结果处理
19
19
 
@@ -75,4 +75,4 @@ category_recommend(
75
75
 
76
76
  ## 本模块不调其它工具
77
77
 
78
- 只调 `category_recommend`。不需要 `item_get` 也不需要反查——将完整类目 DTO 作为 category_json 传给 item_publish;缺少 cat_id/channel_cat_id/tb_cat_id 时不得猜补。
78
+ 只调 `category_recommend`。不需要 `item_get` 也不需要反查——将完整类目 DTO 作为 category_json 传给 item_publish;缺少 cat_id/cat_name/channel_cat_id 时不得猜补;tb_cat_id 为空是正常情况。
@@ -14,22 +14,24 @@ from goofish_cli.core.errors import GoofishError
14
14
  from goofish_cli.core.mtop import call
15
15
 
16
16
 
17
- def _selected_score(data: dict, predict: dict) -> tuple[float | None, str | None]:
18
- explicit = predict.get("confidence")
19
- if isinstance(explicit, (float, int)) and not isinstance(explicit, bool) and math.isfinite(explicit):
20
- return float(explicit), "categoryPredictResult.confidence"
21
- values = []
17
+ def _finite(value: Any) -> float | None:
18
+ if isinstance(value, (float, int)) and not isinstance(value, bool) and math.isfinite(value):
19
+ return float(value)
20
+ return None
21
+
22
+
23
+ def _clicked_candidate(data: dict) -> dict:
24
+ """分类卡片(propertyId -10000)里被选中的候选。
25
+
26
+ 网页发布页以它为准,categoryPredictResult 只作兜底;虚拟类目(如「电子资料」)
27
+ 的 categoryPredictResult 不带类目字段,选中身份只在候选里。
28
+ """
22
29
  for card in data.get("cardList") or []:
23
30
  body = card.get("cardData") or {}
24
- if str(body.get("propertyId")) != "-10000":
25
- continue
26
- for candidate in body.get("valuesList") or []:
27
- keys = ("channelCatId", "tbCatId", "catId")
28
- if all(str(candidate.get(key)) == str(predict[key]) for key in keys if predict.get(key) is not None):
29
- score = candidate.get("score")
30
- if isinstance(score, (float, int)) and not isinstance(score, bool) and math.isfinite(score):
31
- values.append(float(score))
32
- return (values[0], "classification_card.score") if len(values) == 1 else (None, None)
31
+ if str(body.get("propertyId")) == "-10000":
32
+ values = body.get("valuesList") or []
33
+ return next((v for v in values if str(v.get("isClicked")) == "1"), {})
34
+ return {}
33
35
 
34
36
 
35
37
  @command(
@@ -84,15 +86,29 @@ def recommend(
84
86
  version="2.0",
85
87
  spm_cnt="a21ybx.publish.0.0",
86
88
  )
87
- predict = (raw.get("data", {}) or {}).get("categoryPredictResult", {}) or {}
88
- if not predict.get("catId") or not predict.get("channelCatId") or not predict.get("tbCatId"):
89
+ data = raw.get("data", {}) or {}
90
+ predict = data.get("categoryPredictResult", {}) or {}
91
+ clicked = _clicked_candidate(data)
92
+ selected = {
93
+ key: clicked.get(key) or predict.get(key)
94
+ for key in ("catId", "catName", "channelCatId", "tbCatId")
95
+ }
96
+ # tbCatId 可以为空:虚拟/服务类目没有淘宝类目映射,网页端照常以空值发布。
97
+ if not selected["catId"] or not selected["catName"] or not selected["channelCatId"]:
89
98
  raise GoofishError("类目推荐响应缺少选中分类身份,不能继续自动发布", raw=raw)
90
- score, source = _selected_score(raw.get("data") or {}, predict)
99
+ explicit = _finite(predict.get("confidence"))
100
+ clicked_score = _finite(clicked.get("score"))
101
+ if explicit is not None:
102
+ score, source = explicit, "categoryPredictResult.confidence"
103
+ elif clicked_score is not None:
104
+ score, source = clicked_score, "classification_card.score"
105
+ else:
106
+ score, source = None, None
91
107
  return {
92
- "cat_id": str(predict.get("catId", "")),
93
- "cat_name": predict.get("catName", ""),
94
- "channel_cat_id": str(predict.get("channelCatId", "")),
95
- "tb_cat_id": str(predict.get("tbCatId", "")),
108
+ "cat_id": str(selected["catId"]),
109
+ "cat_name": selected["catName"],
110
+ "channel_cat_id": str(selected["channelCatId"]),
111
+ "tb_cat_id": str(selected["tbCatId"] or ""),
96
112
  "confidence": score,
97
113
  "confidence_source": source,
98
114
  "confidence_kind": "model_score_not_calibrated_probability",
@@ -122,8 +122,9 @@ def _money(value: float) -> str:
122
122
 
123
123
 
124
124
  def _category(value: Any) -> None:
125
- if not isinstance(value, dict) or any(not value.get(k) for k in ("cat_id", "cat_name", "channel_cat_id", "tb_cat_id")):
126
- raise GoofishError("已确认类目必须包含 cat_id/cat_name/channel_cat_id/tb_cat_id")
125
+ # tb_cat_id 可为空:虚拟/服务类目没有淘宝类目映射。
126
+ if not isinstance(value, dict) or any(not value.get(k) for k in ("cat_id", "cat_name", "channel_cat_id")):
127
+ raise GoofishError("已确认类目必须包含 cat_id/cat_name/channel_cat_id")
127
128
 
128
129
 
129
130
  def _address(value: Any) -> dict:
@@ -216,7 +217,7 @@ def _build_publish_data(
216
217
  "catId": cat_info["cat_id"],
217
218
  "catName": cat_info["cat_name"],
218
219
  "channelCatId": cat_info["channel_cat_id"],
219
- "tbCatId": cat_info["tb_cat_id"],
220
+ "tbCatId": cat_info.get("tb_cat_id") or "",
220
221
  },
221
222
  "onlyTakeSelf": can_self_pickup,
222
223
  "uniqueCode": cat_info.get("unique_code") or str(time.time_ns() // 1000),
@@ -42,12 +42,16 @@ _REQUIRED_LOGIN_COOKIES = ("_m_h5_tk", "unb", "cookie2")
42
42
  _DEFAULT_QR_TIMEOUT = 120
43
43
 
44
44
 
45
- async def _find_passport_frame(page: Any, timeout_ms: int = 20000) -> Any:
45
+ async def _find_passport_frame(page: Any, timeout_ms: int = 60000) -> Any:
46
46
  """按 URL 轮询 page.frames 找 passport iframe。
47
47
 
48
48
  不用 element_handle.content_frame():iframe 加载中会先 about:blank 再跳到
49
49
  passport 域,期间句柄跨文档失效,报 "Unable to adopt element handle from a
50
50
  different document"。直接轮询 page.frames 按 URL 匹配没有这个问题。
51
+
52
+ timeout 给 60s:登录页改版后 passport iframe 挂载明显变慢——实测
53
+ domcontentloaded ~16s、iframe 元素 ~24s 出现、src 跳到 passport 域 ~39s。
54
+ 旧的 20s 默认会赶在 iframe 就绪前误判"登录页结构又变了"。
51
55
  """
52
56
  deadline = time.monotonic() + timeout_ms / 1000
53
57
  while time.monotonic() < deadline:
@@ -113,8 +117,6 @@ async def _login_via_qr_async(timeout: int) -> list[CookieRecord]:
113
117
 
114
118
  if sandbox:
115
119
  page.on("response", schedule)
116
- # 轮询 cookies:扫码 → 手机确认 → passport 下发完整 session 一般 < 5s
117
- deadline = time.monotonic() + timeout
118
120
  try:
119
121
  await page.goto(HOME_URL, wait_until="domcontentloaded")
120
122
  if not sandbox:
@@ -124,6 +126,10 @@ async def _login_via_qr_async(timeout: int) -> list[CookieRecord]:
124
126
 
125
127
  logger.info(f"[qr] 请用手机闲鱼 App 扫码登录({timeout}s 超时)")
126
128
 
129
+ # timeout 只约束"用户扫码"阶段:登录页改版后 passport iframe 要 ~40s
130
+ # 才挂载,把页面加载算进 deadline 会吃掉大半扫码时间。
131
+ deadline = time.monotonic() + timeout
132
+ # 轮询 cookies:扫码 → 手机确认 → passport 下发完整 session 一般 < 5s
127
133
  while time.monotonic() < deadline:
128
134
  cookies_list = await page.context.cookies()
129
135
  flat = {c["name"]: c["value"] for c in cookies_list}
File without changes
File without changes
File without changes