argo-search 2.14.1 → 2.16.0

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 (245) hide show
  1. package/AGENTS.md +8 -6
  2. package/README.es.md +57 -813
  3. package/README.ja.md +56 -814
  4. package/README.ko.md +56 -812
  5. package/README.md +160 -754
  6. package/README.zh.md +152 -872
  7. package/SKILL.md +22 -23
  8. package/assets/readme/counts.json +1 -1
  9. package/assets/readme/hero.svg +23 -23
  10. package/backends/concept_vectors.bin +0 -0
  11. package/backends/domain_profiles.json +149 -6
  12. package/backends/engine_concept_vectors.json +1525 -1525
  13. package/backends/engine_registry.yaml +139 -30
  14. package/backends/quota_profiles.json +83 -3
  15. package/bin/argo +33 -17
  16. package/config.yaml +189 -33
  17. package/docs/ADDING_NEW_ENGINE.md +10 -0
  18. package/docs/ARGO_INTRO.md +1 -1
  19. package/docs/CHANGELOG.md +38 -0
  20. package/docs/ENGINE_CATALOG.md +102 -89
  21. package/docs/MCP_SETUP.md +10 -1
  22. package/docs/RELEASE_NOTES_v2.14.1.md +4 -4
  23. package/docs/RELEASE_NOTES_v2.15.0.md +50 -0
  24. package/docs/RELEASE_NOTES_v2.16.0.md +58 -0
  25. package/docs/RELEASING.md +1 -1
  26. package/engines/specs/ai_labs.yaml +89 -0
  27. package/engines/specs/archive_org.yaml +1 -1
  28. package/engines/specs/bilibili_hot.yaml +11 -1
  29. package/engines/specs/brave.yaml +3 -3
  30. package/engines/specs/carbon_intensity.yaml +1 -1
  31. package/engines/specs/cisa_alerts.yaml +40 -0
  32. package/engines/specs/cn_ai_news.yaml +10 -8
  33. package/engines/specs/crates.yaml +1 -1
  34. package/engines/specs/crossref.yaml +4 -2
  35. package/engines/specs/crt_sh.yaml +1 -1
  36. package/engines/specs/dblp.yaml +1 -1
  37. package/engines/specs/devto.yaml +1 -1
  38. package/engines/specs/digup.yaml +11 -6
  39. package/engines/specs/docker_hub.yaml +1 -1
  40. package/engines/specs/douyin_hot.yaml +11 -1
  41. package/engines/specs/dw_news.yaml +4 -2
  42. package/engines/specs/eng_blogs.yaml +63 -0
  43. package/engines/specs/europeana.yaml +3 -4
  44. package/engines/specs/europepmc.yaml +1 -1
  45. package/engines/specs/felo.yaml +3 -3
  46. package/engines/specs/firecrawl.yaml +3 -0
  47. package/engines/specs/fourget.yaml +5 -2
  48. package/engines/specs/france24.yaml +6 -4
  49. package/engines/specs/fxtwitter.yaml +30 -7
  50. package/engines/specs/gbfs_nyc.yaml +1 -1
  51. package/engines/specs/gleif.yaml +1 -1
  52. package/engines/specs/gov_regulations.yaml +1 -1
  53. package/engines/specs/grepapp_mcp.yaml +62 -0
  54. package/engines/specs/guardian_rss.yaml +6 -4
  55. package/engines/specs/hf_datasets.yaml +1 -1
  56. package/engines/specs/huggingface.yaml +1 -1
  57. package/engines/specs/itotii.yaml +13 -1
  58. package/engines/specs/keenable.yaml +7 -1
  59. package/engines/specs/linux_do.yaml +63 -0
  60. package/engines/specs/lobsters.yaml +41 -0
  61. package/engines/specs/local_crossref.yaml +3 -1
  62. package/engines/specs/local_github.yaml +1 -1
  63. package/engines/specs/local_npm.yaml +6 -0
  64. package/engines/specs/local_openstreetmap.yaml +1 -1
  65. package/engines/specs/local_seek.yaml +6 -0
  66. package/engines/specs/maven.yaml +1 -1
  67. package/engines/specs/mdn.yaml +1 -1
  68. package/engines/specs/musicbrainz.yaml +1 -1
  69. package/engines/specs/nasa_images.yaml +1 -1
  70. package/engines/specs/nhtsa_vpic.yaml +6 -3
  71. package/engines/specs/npm.yaml +1 -1
  72. package/engines/specs/nuget.yaml +1 -1
  73. package/engines/specs/nvd.yaml +1 -1
  74. package/engines/specs/open_meteo.yaml +1 -1
  75. package/engines/specs/openalex.yaml +4 -2
  76. package/engines/specs/openreview.yaml +1 -1
  77. package/engines/specs/polymarket.yaml +1 -1
  78. package/engines/specs/redskill.yaml +2 -0
  79. package/engines/specs/searxng.yaml +4 -2
  80. package/engines/specs/sec_edgar.yaml +9 -4
  81. package/engines/specs/steam.yaml +1 -1
  82. package/engines/specs/tinyfish.yaml +2 -0
  83. package/engines/specs/tinyfish_news.yaml +2 -0
  84. package/engines/specs/tinyfish_paper.yaml +2 -0
  85. package/engines/specs/toutiao_hot.yaml +11 -1
  86. package/engines/specs/train.yaml +3 -0
  87. package/engines/specs/twitter.yaml +4 -0
  88. package/engines/specs/unpaywall.yaml +6 -0
  89. package/engines/specs/vam.yaml +17 -3
  90. package/engines/specs/weibo_hot.yaml +11 -1
  91. package/engines/specs/wikidata.yaml +1 -1
  92. package/engines/specs/wikipedia.yaml +1 -1
  93. package/engines/specs/wolframalpha.yaml +3 -3
  94. package/engines/specs/xiaohongshu.yaml +2 -0
  95. package/engines/specs/zhihu.yaml +3 -18
  96. package/engines/specs/zhihu_hot_app.yaml +1 -1
  97. package/engines/specs/zhihu_kb.yaml +18 -0
  98. package/engines/specs/zhihu_questions.yaml +19 -0
  99. package/package.json +4 -2
  100. package/packages/dsh-plugin/README.md +9 -14
  101. package/packages/dsh-plugin/dsh/client.js +481 -1037
  102. package/packages/dsh-plugin/dsh/diagnostics.js +71 -20
  103. package/packages/dsh-plugin/dsh/index.js +6 -0
  104. package/packages/dsh-plugin/dsh/runner.js +3 -1
  105. package/packages/dsh-plugin/dsh/workbench-client.js +796 -0
  106. package/packages/dsh-plugin/dsh/workbench-md.js +386 -0
  107. package/packages/dsh-plugin/dsh/workbench-suggestions.js +148 -0
  108. package/packages/dsh-plugin/dsh/workbench.js +966 -0
  109. package/packages/dsh-plugin/icon.svg +23 -0
  110. package/packages/dsh-plugin/package.json +10 -3
  111. package/packages/dsh-plugin/scripts/sync-local.mjs +87 -0
  112. package/packages/dsh-plugin/scripts/sync-local.sh +13 -1
  113. package/packages/dsh-plugin/test/diagnostics.test.js +38 -1
  114. package/packages/dsh-plugin/test/size-gate.test.js +2 -9
  115. package/packages/dsh-plugin/test/workbench.test.js +92 -0
  116. package/scripts/adaptive.py +7 -1
  117. package/scripts/archive_run.py +112 -53
  118. package/scripts/argo_paths.py +42 -5
  119. package/scripts/badcase_ledger.py +117 -9
  120. package/scripts/build_concept_table.py +112 -55
  121. package/scripts/cache.py +6 -2
  122. package/scripts/caliber_isolation.py +60 -23
  123. package/scripts/circuit_breaker.py +72 -11
  124. package/scripts/cli_io.py +20 -2
  125. package/scripts/config_cache.py +44 -1
  126. package/scripts/daemon.py +151 -51
  127. package/scripts/dormant_ledger.py +23 -9
  128. package/scripts/engine_dispatch.py +8 -5
  129. package/scripts/engine_env.py +191 -1
  130. package/scripts/engine_families.py +50 -7
  131. package/scripts/engine_states.py +3 -50
  132. package/scripts/engine_validate.py +13 -45
  133. package/scripts/engines.py +15 -31
  134. package/scripts/engines_base.py +66 -61
  135. package/scripts/engines_builders.py +0 -15
  136. package/scripts/engines_builders_archive.py +4 -3
  137. package/scripts/engines_builders_batch10.py +346 -100
  138. package/scripts/engines_builders_batch11.py +4 -76
  139. package/scripts/engines_builders_batch13.py +4 -3
  140. package/scripts/engines_builders_batch14.py +2 -1
  141. package/scripts/engines_builders_batch15.py +2 -1
  142. package/scripts/engines_builders_batch9.py +16 -25
  143. package/scripts/engines_builders_cn.py +7 -201
  144. package/scripts/engines_builders_data.py +12 -11
  145. package/scripts/engines_builders_data_macro.py +5 -4
  146. package/scripts/engines_builders_dsh.py +2 -1
  147. package/scripts/engines_builders_feeds.py +76 -11
  148. package/scripts/engines_builders_finance.py +2 -1
  149. package/scripts/engines_builders_intl.py +18 -117
  150. package/scripts/engines_builders_media.py +59 -12
  151. package/scripts/engines_builders_pixiv.py +2 -16
  152. package/scripts/engines_builders_science.py +8 -7
  153. package/scripts/engines_builders_search.py +7 -14
  154. package/scripts/engines_builders_skill.py +2 -1
  155. package/scripts/engines_builders_tech.py +8 -17
  156. package/scripts/engines_builders_weather.py +241 -0
  157. package/scripts/engines_fields.py +91 -0
  158. package/scripts/engines_http.py +184 -0
  159. package/scripts/engines_mcp.py +405 -0
  160. package/scripts/engines_parsers.py +13 -369
  161. package/scripts/engines_schema_drift.py +260 -0
  162. package/scripts/evidence.py +13 -0
  163. package/scripts/evidence_loop.py +19 -4
  164. package/scripts/extend_route_labels.py +6 -0
  165. package/scripts/fetch_jina.py +98 -0
  166. package/scripts/fetch_jsrun.py +15 -11
  167. package/scripts/fetch_v3.py +79 -120
  168. package/scripts/fulltext_store.py +42 -1
  169. package/scripts/fxtwitter_api.py +8 -7
  170. package/scripts/gen_engine_catalog.py +2 -2
  171. package/scripts/general_pool.py +15 -4
  172. package/scripts/health_check.py +1 -1
  173. package/scripts/image_vision/vision_probe +0 -0
  174. package/scripts/install.sh +2 -0
  175. package/scripts/link_source.py +65 -24
  176. package/scripts/local_seek_adapter.py +57 -17
  177. package/scripts/matrix_search_eval.py +8 -10
  178. package/scripts/mcp_handlers.py +53 -31
  179. package/scripts/mcp_handlers_surface.py +6 -18
  180. package/scripts/mcp_transport.py +10 -5
  181. package/scripts/min_version_scan.py +7 -3
  182. package/scripts/network_aware.py +7 -13
  183. package/scripts/numeric_verify.py +3 -2
  184. package/scripts/output_transparency.py +3 -0
  185. package/scripts/pre-commit +45 -43
  186. package/scripts/query_understanding.py +30 -6
  187. package/scripts/quota.py +36 -30
  188. package/scripts/rank_signals.py +9 -0
  189. package/scripts/recompute.py +15 -5
  190. package/scripts/recovery.py +38 -29
  191. package/scripts/recovery_runner.py +29 -10
  192. package/scripts/redskill/redskill_engine.py +2 -1
  193. package/scripts/release.py +14 -26
  194. package/scripts/release_check.py +5 -25
  195. package/scripts/replay_eval.py +2 -2
  196. package/scripts/research_cli.py +40 -0
  197. package/scripts/research_notes.py +368 -0
  198. package/scripts/route.py +40 -70
  199. package/scripts/route_audit.py +259 -0
  200. package/scripts/route_combo.py +21 -6
  201. package/scripts/route_domains.py +150 -23
  202. package/scripts/route_lang.py +20 -7
  203. package/scripts/route_log.py +26 -9
  204. package/scripts/route_policy.py +85 -6
  205. package/scripts/route_telemetry_export.py +199 -0
  206. package/scripts/rrf_classic.py +5 -22
  207. package/scripts/search.py +2 -1
  208. package/scripts/search_attribution.py +53 -10
  209. package/scripts/search_entry.py +32 -1
  210. package/scripts/search_output.py +23 -11
  211. package/scripts/search_pipeline.py +15 -3
  212. package/scripts/search_rank.py +21 -11
  213. package/scripts/semantic_evidence.py +394 -178
  214. package/scripts/serp_guard.py +13 -1
  215. package/scripts/settings_page.py +4 -3
  216. package/scripts/single_flight.py +1 -1
  217. package/scripts/social_engines/hackernews_engine.py +2 -1
  218. package/scripts/social_engines/reddit_engine.py +2 -1
  219. package/scripts/social_engines/xiaohongshu_engine.py +2 -1
  220. package/scripts/social_engines/zhihu_engine.py +252 -43
  221. package/scripts/sogou_weixin_browser.py +5 -6
  222. package/scripts/source_audit.py +44 -9
  223. package/scripts/source_ledger.py +2 -15
  224. package/scripts/source_selection.py +45 -20
  225. package/scripts/straggler_policy.py +1 -2
  226. package/scripts/sync_backends.py +17 -0
  227. package/scripts/tfidf_router.py +23 -11
  228. package/scripts/time_utils.py +54 -1
  229. package/scripts/train.py +68 -2
  230. package/scripts/usage_log.py +50 -10
  231. package/scripts/watch.py +3 -3
  232. package/scripts/zhihu_quota.py +2 -1
  233. package/sub-skills/argo-wide-research/SKILL.md +70 -0
  234. package/sub-skills/ego-search/{SKILL.md → README.md} +15 -47
  235. package/sub-skills/ego-search/scripts/ego_search.py +13 -4
  236. package/sub-skills/js-run/{SKILL.md → README.md} +3 -20
  237. package/sub-skills/local-search/{SKILL.md → README.md} +3 -8
  238. package/sub-skills/local-search/engine_registry.py +32 -7
  239. package/sub-skills/local-seek/SKILL.md +20 -22
  240. package/sub-skills/local-seek/scripts/seek_fts.py +58 -3
  241. package/scripts/caliber_dedupe.py +0 -66
  242. package/scripts/engines_builders_batch16.py +0 -13
  243. package/scripts/health_probe.py +0 -253
  244. package/scripts/social_engines/twitter_engine.py +0 -514
  245. package/scripts/sync_installs.py +0 -29
@@ -41,9 +41,10 @@ import urllib.request
41
41
  from datetime import datetime, timedelta, timezone
42
42
  from typing import Any
43
43
 
44
+ from engines_http import UA
44
45
  from engines_base import http_open, note_failure, safe_search
45
46
 
46
- _UA = "argo-search/2.9 (unified-search@local)"
47
+ _UA = UA
47
48
  _YUANBAO_URL = "https://api.wsa.cloud.tencent.com/SearchPro"
48
49
  # 腾讯侧公布的中间价/新闻口径都按北京时间;本机可能不在东八区,日期归一
49
50
  # 必须显式指定偏移,否则跨时区机器上「今天」会错一天。
@@ -48,9 +48,15 @@ from engines_base import (
48
48
  http_open,
49
49
  )
50
50
 
51
- logger = logging.getLogger("unified_search.engines")
51
+ from engines_http import (
52
+ UA, http_json as _shared_http_json,
53
+ http_text as _shared_http_text,
54
+ lazy_logger,
55
+ )
56
+
57
+ logger = lazy_logger()
52
58
 
53
- _UA = "argo-search/2.8 (+batch9)"
59
+ _UA = UA
54
60
 
55
61
  # e-Gov 法令列表进程内缓存(体积大、变动低频)
56
62
  _EGOV_ENTRIES: list[str] | None = None
@@ -74,33 +80,18 @@ def _terms(q: str) -> list[str]:
74
80
 
75
81
 
76
82
 
77
- def _read(resp, engine: str = "") -> bytes:
78
- """读取响应体,容忍 IncompleteRead。
79
-
80
- 大体积响应(e-Gov 法令列表实测 2.7MB)在 http.client 上偶发
81
- `IncompleteRead` —— 此时已读到的部分数据仍然可用(我们先拿头部/整体结构),
82
- 所以接受 partial 而不是直接失败。
83
- """
84
- try:
85
- return resp.read()
86
- except Exception as e: # http.client.IncompleteRead 等
87
- partial = getattr(e, "partial", None)
88
- if partial:
89
- logger.warning(f"{engine} 响应不完整,使用已读部分 {len(partial)}B")
90
- return partial
91
- raise
92
-
93
-
94
83
  def _json(url: str, to: float, engine: str = "") -> Any:
95
- req = urllib.request.Request(url, headers={"User-Agent": _UA, "Accept": "application/json"})
96
- with http_open(req, timeout=to, engine=engine) as resp:
97
- return json.loads(_read(resp, engine).decode("utf-8", "replace"))
84
+ return _shared_http_json(
85
+ url, to, engine=engine, headers={"Accept": "application/json"},
86
+ ua=_UA, accept_partial=True, opener=http_open,
87
+ )
98
88
 
99
89
 
100
90
  def _text(url: str, to: float, engine: str = "", accept: str = "*/*") -> str:
101
- req = urllib.request.Request(url, headers={"User-Agent": _UA, "Accept": accept})
102
- with http_open(req, timeout=to, engine=engine) as resp:
103
- return _read(resp, engine).decode("utf-8", "replace")
91
+ return _shared_http_text(
92
+ url, to, engine=engine, headers={"Accept": accept},
93
+ ua=_UA, accept_partial=True, opener=http_open,
94
+ )
104
95
 
105
96
 
106
97
  # ── WHO DON 疫情暴发通报 ──────────────────────────────────────────────────────
@@ -15,7 +15,7 @@ from typing import Any
15
15
 
16
16
  from engine_env import get_env
17
17
 
18
- from engines_base import safe_search, _run, _resolve, _get_path, _coerce_field, _http_get_raw, http_open, rank_score
18
+ from engines_base import safe_search, _run, _resolve, _get_path, _coerce_field, _http_get_raw, http_open, rank_score, UA
19
19
 
20
20
  logger = logging.getLogger("unified_search.engines")
21
21
 
@@ -204,7 +204,7 @@ def _build_em_miaoxiang_engine(spec: dict[str, Any]) -> Any:
204
204
  headers={
205
205
  "apikey": key,
206
206
  "Content-Type": "application/json",
207
- "User-Agent": "argo-search/2.4 (unified-search@local)",
207
+ "User-Agent": UA,
208
208
  },
209
209
  )
210
210
  try:
@@ -868,49 +868,6 @@ def _build_eastmoney_engine(spec: dict[str, Any]) -> Any:
868
868
  return _engine
869
869
 
870
870
 
871
- # ── itotii 梗百科引擎 ────────────────────────────────────────────────────────
872
-
873
- def _build_itotii_engine(spec: dict[str, Any]) -> Any:
874
- """itotii 梗百科(中文流行语/网络梗词条,WordPress REST API,免认证)"""
875
- timeout = spec.get("timeout", 10)
876
-
877
- @safe_search
878
- def _engine(query: str, n: int = 5, _timeout: float | None = None, **kwargs) -> list[dict[str, Any]]:
879
- import urllib.parse as up
880
- to = _timeout or timeout
881
- url = (
882
- "https://geng.itotii.com/wp-json/wp/v2/posts?search="
883
- + up.quote(query) + f"&per_page={min(n, 10)}"
884
- )
885
- headers = {"User-Agent": "Mozilla/5.0"}
886
- req = urllib.request.Request(url, headers=headers)
887
- try:
888
- with http_open(req, timeout=to, engine=spec.get("_name", "")) as resp:
889
- data = json.loads(resp.read().decode("utf-8", "replace"))
890
- results = []
891
- for p in data:
892
- title = p.get("title", {})
893
- title = title.get("rendered", "") if isinstance(title, dict) else str(title)
894
- content = p.get("content", {})
895
- content = content.get("rendered", "") if isinstance(content, dict) else str(content)
896
- title = re.sub(r"<[^>]+>", "", title).strip()
897
- content = re.sub(r"<[^>]+>", "", content).strip()
898
- if not title:
899
- continue
900
- results.append({
901
- "title": title[:80],
902
- "url": p.get("link", ""),
903
- "snippet": f"{p.get('date', '')[:10]} | {content[:200]}",
904
- "source": "itotii",
905
- "score": max(1.0 - len(results) * 0.1, 0.1),
906
- })
907
- return results[:n]
908
- except Exception as e:
909
- logger.warning(f"itotii 梗百科失败: {e}")
910
- return []
911
- return _engine
912
-
913
-
914
871
  # ── 百度热搜引擎 ─────────────────────────────────────────────────────────────
915
872
 
916
873
  def _build_baidu_hot_engine(spec: dict[str, Any]) -> Any:
@@ -949,74 +906,6 @@ def _build_baidu_hot_engine(spec: dict[str, Any]) -> Any:
949
906
  return _engine
950
907
 
951
908
 
952
- # ── 今日头条热榜引擎 ─────────────────────────────────────────────────────────
953
-
954
- def _build_toutiao_hot_engine(spec: dict[str, Any]) -> Any:
955
- """今日头条热榜(hot-board JSON,免认证)"""
956
- timeout = spec.get("timeout", 10)
957
-
958
- @safe_search
959
- def _engine(query: str, n: int = 10, _timeout: float | None = None, **kwargs) -> list[dict[str, Any]]:
960
- to = _timeout or timeout
961
- url = "https://www.toutiao.com/hot-event/hot-board/?origin=toutiao_pc"
962
- headers = {"User-Agent": "Mozilla/5.0", "Referer": "https://www.toutiao.com/"}
963
- req = urllib.request.Request(url, headers=headers)
964
- try:
965
- with http_open(req, timeout=to, engine=spec.get("_name", "")) as resp:
966
- data = json.loads(resp.read().decode("utf-8", "replace"))
967
- results = []
968
- for i, item in enumerate(data.get("data", [])[:n]):
969
- hot = item.get("HotValue", "")
970
- results.append({
971
- "title": item.get("Title", "")[:60],
972
- "url": item.get("Url", ""),
973
- "snippet": f"热度 {hot}" if hot else "今日头条热榜",
974
- "source": "toutiao_hot",
975
- "score": max(1.0 - i * 0.05, 0.1),
976
- })
977
- return results
978
- except Exception as e:
979
- logger.warning(f"今日头条热榜失败: {e}")
980
- return []
981
- return _engine
982
-
983
-
984
- # ── B站热搜引擎 ──────────────────────────────────────────────────────────────
985
-
986
- def _build_bilibili_hot_engine(spec: dict[str, Any]) -> Any:
987
- """B站热搜(search/square 热搜词,免认证)"""
988
- timeout = spec.get("timeout", 10)
989
-
990
- @safe_search
991
- def _engine(query: str, n: int = 10, _timeout: float | None = None, **kwargs) -> list[dict[str, Any]]:
992
- import urllib.parse as up
993
- to = _timeout or timeout
994
- url = "https://api.bilibili.com/x/web-interface/search/square?limit=20"
995
- headers = {"User-Agent": "Mozilla/5.0", "Referer": "https://www.bilibili.com"}
996
- req = urllib.request.Request(url, headers=headers)
997
- try:
998
- with http_open(req, timeout=to, engine=spec.get("_name", "")) as resp:
999
- data = json.loads(resp.read().decode("utf-8", "replace"))
1000
- items = data.get("data", {}).get("trending", {}).get("list", [])
1001
- results = []
1002
- for i, item in enumerate(items[:n]):
1003
- kw = item.get("keyword", "")
1004
- if not kw:
1005
- continue
1006
- results.append({
1007
- "title": kw[:60],
1008
- "url": "https://search.bilibili.com/all?keyword=" + up.quote(kw),
1009
- "snippet": "B站热搜",
1010
- "source": "bilibili_hot",
1011
- "score": max(1.0 - i * 0.05, 0.1),
1012
- })
1013
- return results
1014
- except Exception as e:
1015
- logger.warning(f"B站热搜失败: {e}")
1016
- return []
1017
- return _engine
1018
-
1019
-
1020
909
  # ── 知乎全网搜索(global_search,需 ZHIHU_ACCESS_SECRET)─────────────────────
1021
910
 
1022
911
  # site:/host: 站点限定语法 → Filter host=="..." 表达式。
@@ -1090,7 +979,7 @@ def _build_zhihu_global_engine(spec: dict[str, Any]) -> Any:
1090
979
  "Authorization": f"Bearer {secret}",
1091
980
  "X-Request-Timestamp": str(int(time.time())),
1092
981
  "Content-Type": "application/json",
1093
- "User-Agent": "argo-search/2.6 (unified-search@local)",
982
+ "User-Agent": UA,
1094
983
  }
1095
984
  try:
1096
985
  with http_open(urllib.request.Request(url, headers=headers), timeout=to, engine=spec.get("_name", "")) as resp:
@@ -1227,7 +1116,7 @@ def _build_zhihu_user_engine(spec: dict[str, Any]) -> Any:
1227
1116
  "Authorization": f"Bearer {secret}",
1228
1117
  "X-Request-Timestamp": str(int(time.time())),
1229
1118
  "Content-Type": "application/json",
1230
- "User-Agent": "argo-search/2.6 (unified-search@local)",
1119
+ "User-Agent": UA,
1231
1120
  }
1232
1121
  try:
1233
1122
  with http_open(urllib.request.Request(url, headers=headers), timeout=to, engine=spec.get("_name", "")) as resp:
@@ -1460,7 +1349,7 @@ def _build_std_samr_engine(spec: dict[str, Any]) -> Any:
1460
1349
  to = _timeout or timeout
1461
1350
  url = ("https://std.samr.gov.cn/gb/search/gbQueryPage"
1462
1351
  f"?searchText={urllib.parse.quote(q)}&pageNumber=1&pageSize={min(max(int(n), 1), 50)}")
1463
- raw = _http_get_raw(url, {"User-Agent": "argo-search/1.0 (+std_samr)", "Accept": "application/json"},
1352
+ raw = _http_get_raw(url, {"User-Agent": UA, "Accept": "application/json"},
1464
1353
  to, engine=spec.get("_name", "std_samr"))
1465
1354
  if raw is None:
1466
1355
  return []
@@ -1863,7 +1752,7 @@ def _build_people_daily_engine(spec: dict[str, Any]) -> Any:
1863
1752
  "hasTitle": True, "hasContent": True, "isFuzzy": True,
1864
1753
  "type": 0, "sortType": 2, "startTime": 0, "endTime": 0,
1865
1754
  }).encode("utf-8"),
1866
- headers={"Content-Type": "application/json", "User-Agent": "argo-search/1.0 (+people_daily)"},
1755
+ headers={"Content-Type": "application/json", "User-Agent": UA},
1867
1756
  method="POST",
1868
1757
  )
1869
1758
  try:
@@ -1999,7 +1888,7 @@ def _build_wikisource_engine(spec: dict[str, Any]) -> Any:
1999
1888
  to = _timeout or timeout
2000
1889
  url = ("https://zh.wikisource.org/w/api.php?action=query&format=json&list=search"
2001
1890
  f"&srsearch={urllib.parse.quote(q)}&srlimit={min(max(int(n), 1), 20)}")
2002
- raw = _http_get_raw(url, {"User-Agent": "argo-search/1.0 (+wikisource)", "Accept": "application/json"},
1891
+ raw = _http_get_raw(url, {"User-Agent": UA, "Accept": "application/json"},
2003
1892
  to, engine=spec.get("_name", "wikisource"))
2004
1893
  if raw is None:
2005
1894
  return []
@@ -2026,89 +1915,6 @@ def _build_wikisource_engine(spec: dict[str, Any]) -> Any:
2026
1915
 
2027
1916
  # ── 微博热搜榜引擎 ─────────────────────────────────────────────────────────────
2028
1917
 
2029
- def _build_weibo_hot_engine(spec: dict[str, Any]) -> Any:
2030
- """微博热搜榜(weibo.com/ajax/side/hotSearch,免登录)
2031
-
2032
- 榜单型源:查询词只作路由触发,不参与内容过滤(见 config 的 relevance_check: false)。
2033
- """
2034
- timeout = spec.get("timeout", 10)
2035
-
2036
- @safe_search
2037
- def _engine(query: str, n: int = 10, _timeout: float | None = None, **kwargs) -> list[dict[str, Any]]:
2038
- to = _timeout or timeout
2039
- url = "https://weibo.com/ajax/side/hotSearch"
2040
- headers = {
2041
- "User-Agent": "Mozilla/5.0",
2042
- # 缺 Referer 时上游直接返回 {"error":"Forbidden"}(实测)
2043
- "Referer": "https://weibo.com/",
2044
- }
2045
- req = urllib.request.Request(url, headers=headers)
2046
- try:
2047
- with http_open(req, timeout=to, engine=spec.get("_name", "")) as resp:
2048
- d = json.loads(resp.read().decode("utf-8", "replace"))
2049
- rows = (d.get("data") or {}).get("realtime") or []
2050
- results = []
2051
- for i, it in enumerate(rows):
2052
- if len(results) >= n:
2053
- break
2054
- word = str(it.get("word") or "").strip()
2055
- if not word:
2056
- continue
2057
- rank = it.get("realpos") or (i + 1)
2058
- label = str(it.get("label_name") or "").strip()
2059
- num = it.get("num") or 0
2060
- results.append({
2061
- "title": word[:80],
2062
- "url": "https://s.weibo.com/weibo?q=" + urllib.parse.quote("#" + word + "#"),
2063
- "snippet": f"微博热搜 第{rank}位 · 热度 {num}" + (f" · {label}" if label else ""),
2064
- "source": "weibo_hot",
2065
- "score": max(1.0 - len(results) * 0.02, 0.2),
2066
- })
2067
- return results
2068
- except Exception as e:
2069
- logger.warning(f"微博热搜榜失败: {e}")
2070
- return []
2071
- return _engine
2072
-
2073
-
2074
- # ── 抖音热榜引擎 ─────────────────────────────────────────────────────────────
2075
-
2076
- def _build_douyin_hot_engine(spec: dict[str, Any]) -> Any:
2077
- """抖音热榜(iesdouyin web api,免认证,榜单型)"""
2078
- timeout = spec.get("timeout", 10)
2079
-
2080
- @safe_search
2081
- def _engine(query: str, n: int = 10, _timeout: float | None = None, **kwargs) -> list[dict[str, Any]]:
2082
- to = _timeout or timeout
2083
- url = "https://www.iesdouyin.com/web/api/v2/hotsearch/billboard/word/"
2084
- headers = {"User-Agent": "Mozilla/5.0", "Referer": "https://www.douyin.com/"}
2085
- req = urllib.request.Request(url, headers=headers)
2086
- try:
2087
- with http_open(req, timeout=to, engine=spec.get("_name", "")) as resp:
2088
- d = json.loads(resp.read().decode("utf-8", "replace"))
2089
- rows = d.get("word_list") or []
2090
- results = []
2091
- for i, it in enumerate(rows):
2092
- if len(results) >= n:
2093
- break
2094
- word = str(it.get("word") or "").strip()
2095
- if not word:
2096
- continue
2097
- hot = it.get("hot_value") or 0
2098
- results.append({
2099
- "title": word[:80],
2100
- "url": "https://www.douyin.com/search/" + urllib.parse.quote(word),
2101
- "snippet": f"抖音热榜 第{i + 1}位 · 热度 {hot}",
2102
- "source": "douyin_hot",
2103
- "score": max(1.0 - len(results) * 0.02, 0.2),
2104
- })
2105
- return results
2106
- except Exception as e:
2107
- logger.warning(f"抖音热榜失败: {e}")
2108
- return []
2109
- return _engine
2110
-
2111
-
2112
1918
  # ── CSDN 搜索 ────────────────────────────────────────────────────────────────
2113
1919
 
2114
1920
  _EM_TAG_RE = re.compile(r"</?em>")
@@ -17,6 +17,7 @@ from typing import Any
17
17
 
18
18
  from cjk_tokens import cjk_term_grams, signal_tokens
19
19
  from engine_env import get_env
20
+ from engines_http import UA
20
21
  from engines_base import (
21
22
  rank_score,
22
23
  safe_search, _run, _resolve, _get_path, _coerce_field, _detect_anti_bot,
@@ -42,7 +43,7 @@ def _build_open_library_engine(spec: dict[str, Any]) -> Any:
42
43
  })
43
44
  try:
44
45
  with http_open(urllib.request.Request(
45
- url, headers={"User-Agent": "argo-search/2.4 (unified-search@local)"}), timeout=to, engine=spec.get("_name", "")) as resp:
46
+ url, headers={"User-Agent": UA}), timeout=to, engine=spec.get("_name", "")) as resp:
46
47
  data = json.loads(resp.read().decode("utf-8", "replace"))
47
48
  except Exception as e:
48
49
  logger.warning(f"Open Library 失败: {e}")
@@ -96,7 +97,7 @@ def _build_weread_engine(spec: dict[str, Any]) -> Any:
96
97
  headers={
97
98
  "Authorization": f"Bearer {key}",
98
99
  "Content-Type": "application/json",
99
- "User-Agent": "argo-search/2.4 (unified-search@local)",
100
+ "User-Agent": UA,
100
101
  },
101
102
  )
102
103
  try:
@@ -225,7 +226,7 @@ def _build_free_dictionary_engine(spec: dict[str, Any]) -> Any:
225
226
  url = f"https://api.dictionaryapi.dev/api/v2/entries/en/{up.quote(word)}"
226
227
  try:
227
228
  with http_open(urllib.request.Request(
228
- url, headers={"User-Agent": "argo-search/2.4"}), timeout=to, engine=spec.get("_name", "")) as resp:
229
+ url, headers={"User-Agent": UA}), timeout=to, engine=spec.get("_name", "")) as resp:
229
230
  entries = json.loads(resp.read().decode("utf-8", "replace"))
230
231
  except Exception:
231
232
  return []
@@ -362,7 +363,7 @@ def _build_pypi_engine(spec: dict[str, Any]) -> Any:
362
363
  to = _timeout or timeout
363
364
  results: list[dict[str, Any]] = []
364
365
  seen: set[str] = set()
365
- headers = {"User-Agent": "argo-search/2.5 (unified-search@local)", "Accept": "application/json"}
366
+ headers = {"User-Agent": UA, "Accept": "application/json"}
366
367
  for _rk4, name in enumerate(_candidates(query)):
367
368
  if len(results) >= n:
368
369
  break
@@ -479,7 +480,7 @@ def _build_models_dev_engine(spec: dict[str, Any]) -> Any:
479
480
  if cached is None or (now - ts) > _MODELS_DEV_TTL:
480
481
  req = urllib.request.Request(
481
482
  "https://models.dev/api.json",
482
- headers={"User-Agent": "argo-search/1.0 (+models.dev)"},
483
+ headers={"User-Agent": UA},
483
484
  )
484
485
  with http_open(req, timeout=to, engine=spec.get("_name", "")) as resp:
485
486
  cached = json.loads(resp.read().decode("utf-8"))
@@ -592,7 +593,7 @@ def _build_qweather_engine(spec: dict[str, Any]) -> Any:
592
593
 
593
594
  # 1) GeoAPI: 城市 → LocationID
594
595
  geo_url = f"https://geoapi.qweather.com/v2/city/lookup?location={up.quote(city)}&key={key}"
595
- req = urllib.request.Request(geo_url, headers={"User-Agent": "argo-search/1.0"})
596
+ req = urllib.request.Request(geo_url, headers={"User-Agent": UA})
596
597
  with http_open(req, timeout=to, engine=spec.get("_name", "")) as resp:
597
598
  geo = json.loads(resp.read().decode("utf-8"))
598
599
  locations = geo.get("location") or []
@@ -604,7 +605,7 @@ def _build_qweather_engine(spec: dict[str, Any]) -> Any:
604
605
 
605
606
  # 2) 实时天气
606
607
  now_url = f"https://devapi.qweather.com/v7/weather/now?location={loc_id}&key={key}"
607
- req2 = urllib.request.Request(now_url, headers={"User-Agent": "argo-search/1.0"})
608
+ req2 = urllib.request.Request(now_url, headers={"User-Agent": UA})
608
609
  with http_open(req2, timeout=to, engine=spec.get("_name", "")) as resp:
609
610
  data = json.loads(resp.read().decode("utf-8"))
610
611
  now = data.get("now") or {}
@@ -731,7 +732,7 @@ def _build_rfc_editor_engine(spec: dict[str, Any]) -> Any:
731
732
  「RFC 9000」直接定位单篇;「QUIC RFC」按标题搜索 RFC 类型文档。
732
733
  """
733
734
  timeout = spec.get("timeout", 15)
734
- _HEADERS = {"User-Agent": "argo-search/2.6 (unified-search@local)", "Accept": "application/json"}
735
+ _HEADERS = {"User-Agent": UA, "Accept": "application/json"}
735
736
 
736
737
  def _jget(url: str, to: float) -> dict:
737
738
  req = urllib.request.Request(url, headers=_HEADERS)
@@ -813,7 +814,7 @@ def _build_marginalia_engine(spec: dict[str, Any]) -> Any:
813
814
  url = f"{base}/search?query={up.quote(query)}"
814
815
  try:
815
816
  with http_open(urllib.request.Request(
816
- url, headers={"User-Agent": "argo-search/2.4 (unified-search@local)"}), timeout=to, engine=spec.get("_name", "")) as resp:
817
+ url, headers={"User-Agent": UA}), timeout=to, engine=spec.get("_name", "")) as resp:
817
818
  page = resp.read().decode("utf-8", "replace")
818
819
  except Exception as e:
819
820
  logger.warning(f"Marginalia 失败: {e}")
@@ -824,7 +825,7 @@ def _build_marginalia_engine(spec: dict[str, Any]) -> Any:
824
825
  try:
825
826
  with http_open(urllib.request.Request(
826
827
  base + gate.group(1).replace("&amp;", "&"),
827
- headers={"User-Agent": "argo-search/2.4 (unified-search@local)"}), timeout=to, engine=spec.get("_name", "")) as resp:
828
+ headers={"User-Agent": UA}), timeout=to, engine=spec.get("_name", "")) as resp:
828
829
  page = resp.read().decode("utf-8", "replace")
829
830
  except Exception as e:
830
831
  logger.warning(f"Marginalia sst 复访失败: {e}")
@@ -885,7 +886,7 @@ def _build_wiby_engine(spec: dict[str, Any]) -> Any:
885
886
  url = f"https://wiby.me/json/?q={up.quote(query)}"
886
887
  try:
887
888
  with http_open(urllib.request.Request(
888
- url, headers={"User-Agent": "argo-search/2.4 (unified-search@local)"}), timeout=to, engine=spec.get("_name", "")) as resp:
889
+ url, headers={"User-Agent": UA}), timeout=to, engine=spec.get("_name", "")) as resp:
889
890
  data = json.loads(resp.read().decode("utf-8", "replace"))
890
891
  except Exception as e:
891
892
  logger.warning(f"Wiby 失败: {e}")
@@ -16,6 +16,7 @@ import urllib.parse
16
16
  import urllib.request
17
17
  from typing import Any
18
18
 
19
+ from engines_http import UA
19
20
  from engines_base import (
20
21
  safe_search, _run, _resolve, _get_path, _coerce_field, _detect_anti_bot,
21
22
  http_open, rank_score,
@@ -94,7 +95,7 @@ def _build_fred_engine(spec: dict[str, Any]) -> Any:
94
95
  return []
95
96
  url = f"https://fred.stlouisfed.org/graph/fredgraph.csv?id={series_id}"
96
97
  try:
97
- req = urllib.request.Request(url, headers={"User-Agent": "argo-search/2.4 (unified-search@local)"})
98
+ req = urllib.request.Request(url, headers={"User-Agent": UA})
98
99
  with http_open(req, timeout=to, engine=spec.get("_name", "")) as resp:
99
100
  text = resp.read().decode("utf-8", "replace")
100
101
  except Exception as e:
@@ -258,7 +259,7 @@ def _build_fx_rate_engine(spec: dict[str, Any]) -> Any:
258
259
  if not base or not target:
259
260
  return []
260
261
  try:
261
- req = urllib.request.Request(api_url + base, headers={"User-Agent": "argo-search/2.4 (unified-search@local)"})
262
+ req = urllib.request.Request(api_url + base, headers={"User-Agent": UA})
262
263
  with http_open(req, timeout=to, engine=spec.get("_name", "")) as resp:
263
264
  data = json.loads(resp.read().decode("utf-8", "replace"))
264
265
  except Exception as e:
@@ -331,7 +332,7 @@ def _build_worldbank_engine(spec: dict[str, Any]) -> Any:
331
332
  def _engine(query: str, n: int = 5, _timeout: float | None = None, **kwargs) -> list[dict[str, Any]]:
332
333
  import urllib.parse as up
333
334
  to = _timeout or timeout
334
- headers = {"User-Agent": "argo-search/2.4 (unified-search@local)"}
335
+ headers = {"User-Agent": UA}
335
336
  cc, ind, ind_label = _parse(query)
336
337
  if not cc or not ind:
337
338
  return []
@@ -693,7 +694,7 @@ def _build_eurostat_engine(spec: dict[str, Any]) -> Any:
693
694
  支持 EU 国家/欧盟/欧元区的 GDP、人均GDP、失业率、人口年度查询。
694
695
  """
695
696
  timeout = spec.get("timeout", 15)
696
- _HEADERS = {"User-Agent": "argo-search/2.6 (unified-search@local)", "Accept": "application/json"}
697
+ _HEADERS = {"User-Agent": UA, "Accept": "application/json"}
697
698
  _BASE = "https://ec.europa.eu/eurostat/api/dissemination/statistics/1.0/data"
698
699
 
699
700
  def _jget(url: str, to: float) -> dict:
@@ -31,6 +31,7 @@ import urllib.request
31
31
  from pathlib import Path
32
32
  from typing import Any
33
33
 
34
+ from engines_http import UA
34
35
  from engines_base import safe_search, http_open, rank_score
35
36
 
36
37
  # 上游:静态全量目录。Cloudflare 前置,支持 ETag(本 builder 刻意不用,见文件头)。
@@ -116,7 +117,7 @@ def _load_plugins(timeout: float) -> list[dict[str, Any]]:
116
117
  try:
117
118
  req = urllib.request.Request(
118
119
  _DSHOPEN_INDEX_URL,
119
- headers={"User-Agent": "argo-search/1.0", "Accept": "application/json"},
120
+ headers={"User-Agent": UA, "Accept": "application/json"},
120
121
  )
121
122
  with http_open(req, timeout=timeout, engine="dshopen") as resp:
122
123
  payload = json.loads(resp.read())
@@ -11,11 +11,14 @@
11
11
  ## 两种形态,按数据性质分(spec 的 feed_mode 决定)
12
12
 
13
13
  **hot(热榜语义)** —— 新闻 RSS 走这条。种子是固定的最近 N 条,本质是
14
- 实时流而不是检索索引,所以它**忽略 query、返回最新条目**,归入 hot_trending
15
- 族。这是仓内既有分层的要求:engine_families._REFILL_EXCLUDED_FAMILIES 把
16
- hot_trending 排除在通用 combo 回填之外,理由是「产出非『查询相关』内容,
17
- 回填只会引入噪声」。实时流应当由「热搜/今日要闻」这类域按需取用,
18
- 不参与话题检索的槽位竞争。
14
+ 实时流而不是检索索引,所以它**忽略 query、返回最新条目**。新闻 RSS 归
15
+ world_news 族(2026-11-11 从 hot_trending 移出:热榜族与百度/微博/抖音
16
+ 热榜共用 dedupe_by_family(max_per_family=2) 名额,国际新闻流不该争位)。
17
+ engine_families._REFILL_EXCLUDED_FAMILIES 同时排除了 hot_trending 与
18
+ world_news——两者都产出「非查询相关」内容,回填通用 combo 只会引入噪声。
19
+ 实时流应当由「热搜/今日要闻」这类域按需取用,不参与话题检索的槽位竞争。
20
+ world_news 还是语言绑定族:只声明 en 的源在中文查询里会被语言互斥摘除,
21
+ 这点由 route._filter_lang_bound_family 决定,与本构建器无关。
19
22
 
20
23
  **filter(本地过滤)** —— 事实核查源走这条。核查文不是实时流,而是
21
24
  「某个声明被判定为真伪」的查询型内容,用户问的是具体说法,所以本地关键词
@@ -63,6 +66,49 @@ _FEED_TTL_S = 300.0
63
66
  _feed_cache: dict[str, tuple[float, list[dict[str, Any]]]] = {}
64
67
 
65
68
 
69
+ def _read_disk_feed(url: str) -> list[dict[str, Any]] | None:
70
+ """跨进程轻量磁盘缓存(TTL 300s,避免 CLI 进程频繁重拉 RSS)。"""
71
+ try:
72
+ import argo_paths
73
+ p = argo_paths.state_path("feed_cache.json")
74
+ if not p.is_file():
75
+ return None
76
+ import json
77
+ with open(p, "r", encoding="utf-8") as f:
78
+ data = json.load(f)
79
+ entry = data.get(url)
80
+ if isinstance(entry, dict) and (time.time() - float(entry.get("ts", 0))) < _FEED_TTL_S:
81
+ return entry.get("items")
82
+ except Exception:
83
+ pass
84
+ return None
85
+
86
+
87
+ def _write_disk_feed(url: str, items: list[dict[str, Any]]) -> None:
88
+ """原子更新跨进程轻量磁盘缓存(读改写全程持锁,防并发互覆盖)。"""
89
+ if not items or "example.test" in url:
90
+ return
91
+ try:
92
+ import argo_paths
93
+ import json
94
+ p = argo_paths.state_path("feed_cache.json")
95
+ with argo_paths.file_lock(p):
96
+ data: dict[str, Any] = {}
97
+ if p.is_file():
98
+ try:
99
+ with open(p, "r", encoding="utf-8") as f:
100
+ data = json.load(f)
101
+ except Exception:
102
+ data = {}
103
+ data[url] = {"ts": time.time(), "items": items}
104
+ now = time.time()
105
+ # 清理 24h 前历史条目,防无界膨胀
106
+ data = {k: v for k, v in data.items() if isinstance(v, dict) and (now - float(v.get("ts", 0))) < 86400}
107
+ argo_paths.atomic_write_json(p, data)
108
+ except Exception:
109
+ pass
110
+
111
+
66
112
  def _clean(text: str) -> str:
67
113
  """种子字段 → 纯文本(CDATA 安全)。"""
68
114
  if not text:
@@ -256,6 +302,10 @@ def _build_rss_feed_engine(spec: dict[str, Any]) -> Any:
256
302
  min_ratio = float(spec.get("match_min_ratio", 0.34))
257
303
  snippet_max = int(spec.get("snippet_max", 300))
258
304
  hot_base = float(spec.get("hot_base_score", 0.55))
305
+ # 部分站点(如 linux.do)的 Cloudflare 按 TLS 指纹拦 Python 客户端:
306
+ # urllib 403、curl/curl_cffi 200。声明 tls_impersonate: true 的源走
307
+ # curl_cffi 指纹伪造;其余源保持 urllib 路径,行为不变。
308
+ tls_impersonate = bool(spec.get("tls_impersonate"))
259
309
 
260
310
  def _row(it: dict[str, Any], rank: int, score: float,
261
311
  label: str = "") -> dict[str, Any]:
@@ -275,20 +325,35 @@ def _build_rss_feed_engine(spec: dict[str, Any]) -> Any:
275
325
  hit = _feed_cache.get(url)
276
326
  if hit and (time.monotonic() - hit[0]) < _FEED_TTL_S:
277
327
  return hit[1]
328
+ disk_hit = _read_disk_feed(url)
329
+ if disk_hit is not None:
330
+ _feed_cache[url] = (time.monotonic(), disk_hit)
331
+ return disk_hit
278
332
  if one_timeout <= 0:
279
333
  return []
280
334
  # 实测 lobste.rs 会偶发 TLS EOF,重试一次;仍失败只丢这一份。
281
335
  last_exc: Exception | None = None
282
336
  for attempt in (1, 2):
283
337
  try:
284
- req = urllib.request.Request(
285
- url, headers={"User-Agent": _UA, "Accept": "*/*"})
286
- with http_open(req, timeout=one_timeout, engine=name) as resp:
287
- # utf-8-sig 去掉美联储 press_all.xml 开头的 BOM。
288
- # ElementTree 见到 U+FEFF 会整份解析失败。
289
- raw = resp.read().decode("utf-8-sig", "replace")
338
+ if tls_impersonate:
339
+ from http_client import HttpClient
340
+ client = HttpClient(timeout=one_timeout, max_retries=0)
341
+ resp = client.get_impersonated(
342
+ url, extra_headers={"User-Agent": _UA,
343
+ "Accept": "*/*"})
344
+ if resp.get("status") != 200:
345
+ raise IOError(f"HTTP {resp.get('status')}")
346
+ raw = resp.get("text") or ""
347
+ else:
348
+ req = urllib.request.Request(
349
+ url, headers={"User-Agent": _UA, "Accept": "*/*"})
350
+ with http_open(req, timeout=one_timeout, engine=name) as resp:
351
+ # utf-8-sig 去掉美联储 press_all.xml 开头的 BOM。
352
+ # ElementTree 见到 U+FEFF 会整份解析失败。
353
+ raw = resp.read().decode("utf-8-sig", "replace")
290
354
  items = _parse_feed(raw)
291
355
  _feed_cache[url] = (time.monotonic(), items)
356
+ _write_disk_feed(url, items)
292
357
  return items
293
358
  except Exception as exc:
294
359
  last_exc = exc
@@ -16,6 +16,7 @@ import urllib.request
16
16
  from typing import Any
17
17
 
18
18
  from engine_env import get_env
19
+ from engines_http import UA
19
20
  from engines_base import (
20
21
  rank_score,
21
22
  safe_search, _detect_anti_bot,
@@ -220,7 +221,7 @@ def _build_opencorporates_engine(spec: dict[str, Any]) -> Any:
220
221
  f"?q={urllib.parse.quote(q2)}&per_page={min(n, 10)}"
221
222
  + (f"&api_token={urllib.parse.quote(_token)}" if _token else "")
222
223
  )
223
- headers = {"User-Agent": "argo-search/2.6 (unified-search@local)", "Accept": "application/json"}
224
+ headers = {"User-Agent": UA, "Accept": "application/json"}
224
225
  try:
225
226
  with http_open(urllib.request.Request(url, headers=headers), timeout=to, engine=spec.get("_name", "")) as resp:
226
227
  data = json.loads(resp.read().decode("utf-8", "replace"))