argo-search 2.14.1 → 2.15.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.
- package/AGENTS.md +8 -6
- package/README.es.md +54 -832
- package/README.ja.md +53 -833
- package/README.ko.md +53 -831
- package/README.md +126 -769
- package/README.zh.md +124 -893
- package/SKILL.md +17 -18
- package/assets/readme/counts.json +1 -1
- package/assets/readme/hero.svg +23 -23
- package/backends/concept_vectors.bin +0 -0
- package/backends/domain_profiles.json +42 -0
- package/backends/engine_concept_vectors.json +1525 -1525
- package/backends/engine_registry.yaml +124 -28
- package/backends/quota_profiles.json +70 -0
- package/bin/argo +30 -17
- package/config.yaml +173 -33
- package/docs/ADDING_NEW_ENGINE.md +10 -0
- package/docs/ARGO_INTRO.md +1 -1
- package/docs/CHANGELOG.md +23 -0
- package/docs/ENGINE_CATALOG.md +97 -85
- package/docs/MCP_SETUP.md +1 -1
- package/docs/RELEASE_NOTES_v2.14.1.md +4 -4
- package/docs/RELEASE_NOTES_v2.15.0.md +50 -0
- package/docs/RELEASING.md +1 -1
- package/engines/specs/ai_labs.yaml +89 -0
- package/engines/specs/bilibili_hot.yaml +11 -1
- package/engines/specs/brave.yaml +3 -3
- package/engines/specs/cisa_alerts.yaml +40 -0
- package/engines/specs/cn_ai_news.yaml +10 -8
- package/engines/specs/digup.yaml +11 -6
- package/engines/specs/douyin_hot.yaml +11 -1
- package/engines/specs/dw_news.yaml +4 -2
- package/engines/specs/eng_blogs.yaml +63 -0
- package/engines/specs/europeana.yaml +3 -4
- package/engines/specs/felo.yaml +3 -3
- package/engines/specs/firecrawl.yaml +3 -0
- package/engines/specs/fourget.yaml +5 -2
- package/engines/specs/france24.yaml +6 -4
- package/engines/specs/fxtwitter.yaml +29 -6
- package/engines/specs/grepapp_mcp.yaml +62 -0
- package/engines/specs/guardian_rss.yaml +6 -4
- package/engines/specs/itotii.yaml +13 -1
- package/engines/specs/lobsters.yaml +41 -0
- package/engines/specs/local_seek.yaml +6 -0
- package/engines/specs/open_meteo.yaml +1 -1
- package/engines/specs/redskill.yaml +2 -0
- package/engines/specs/searxng.yaml +4 -2
- package/engines/specs/sec_edgar.yaml +8 -3
- package/engines/specs/tinyfish.yaml +2 -0
- package/engines/specs/tinyfish_news.yaml +2 -0
- package/engines/specs/tinyfish_paper.yaml +2 -0
- package/engines/specs/toutiao_hot.yaml +11 -1
- package/engines/specs/train.yaml +3 -0
- package/engines/specs/twitter.yaml +4 -0
- package/engines/specs/unpaywall.yaml +6 -0
- package/engines/specs/vam.yaml +17 -3
- package/engines/specs/weibo_hot.yaml +11 -1
- package/engines/specs/wolframalpha.yaml +3 -3
- package/engines/specs/xiaohongshu.yaml +2 -0
- package/engines/specs/zhihu.yaml +3 -18
- package/engines/specs/zhihu_kb.yaml +18 -0
- package/engines/specs/zhihu_questions.yaml +19 -0
- package/package.json +3 -2
- package/packages/dsh-plugin/README.md +9 -14
- package/packages/dsh-plugin/dsh/client.js +467 -1024
- package/packages/dsh-plugin/dsh/diagnostics.js +71 -20
- package/packages/dsh-plugin/dsh/runner.js +2 -0
- package/packages/dsh-plugin/package.json +8 -3
- package/packages/dsh-plugin/scripts/sync-local.mjs +87 -0
- package/packages/dsh-plugin/scripts/sync-local.sh +13 -1
- package/packages/dsh-plugin/test/diagnostics.test.js +38 -1
- package/packages/dsh-plugin/test/size-gate.test.js +2 -9
- package/scripts/adaptive.py +7 -1
- package/scripts/archive_run.py +112 -53
- package/scripts/argo_paths.py +40 -3
- package/scripts/badcase_ledger.py +108 -9
- package/scripts/build_concept_table.py +112 -55
- package/scripts/cache.py +5 -1
- package/scripts/caliber_isolation.py +60 -23
- package/scripts/circuit_breaker.py +56 -8
- package/scripts/cli_io.py +20 -2
- package/scripts/config_cache.py +31 -0
- package/scripts/daemon.py +146 -51
- package/scripts/dormant_ledger.py +23 -9
- package/scripts/engine_dispatch.py +3 -3
- package/scripts/engine_env.py +182 -1
- package/scripts/engine_families.py +50 -7
- package/scripts/engine_states.py +3 -50
- package/scripts/engine_validate.py +13 -45
- package/scripts/engines.py +15 -31
- package/scripts/engines_base.py +42 -58
- package/scripts/engines_builders.py +0 -15
- package/scripts/engines_builders_batch10.py +346 -100
- package/scripts/engines_builders_batch11.py +2 -75
- package/scripts/engines_builders_batch9.py +15 -24
- package/scripts/engines_builders_cn.py +0 -194
- package/scripts/engines_builders_feeds.py +55 -5
- package/scripts/engines_builders_intl.py +15 -115
- package/scripts/engines_builders_pixiv.py +2 -16
- package/scripts/engines_builders_search.py +7 -14
- package/scripts/engines_builders_tech.py +5 -14
- package/scripts/engines_builders_weather.py +236 -0
- package/scripts/engines_fields.py +91 -0
- package/scripts/engines_http.py +135 -0
- package/scripts/engines_mcp.py +383 -0
- package/scripts/engines_parsers.py +13 -369
- package/scripts/engines_schema_drift.py +260 -0
- package/scripts/evidence.py +13 -0
- package/scripts/evidence_loop.py +4 -3
- package/scripts/fetch_jsrun.py +15 -11
- package/scripts/fetch_v3.py +28 -28
- package/scripts/fulltext_store.py +42 -1
- package/scripts/fxtwitter_api.py +8 -7
- package/scripts/gen_engine_catalog.py +2 -2
- package/scripts/general_pool.py +15 -4
- package/scripts/health_check.py +1 -1
- package/scripts/link_source.py +65 -24
- package/scripts/local_seek_adapter.py +57 -17
- package/scripts/mcp_handlers.py +53 -31
- package/scripts/mcp_handlers_surface.py +6 -18
- package/scripts/mcp_transport.py +1 -1
- package/scripts/min_version_scan.py +7 -3
- package/scripts/network_aware.py +7 -13
- package/scripts/pre-commit +45 -43
- package/scripts/query_understanding.py +30 -6
- package/scripts/quota.py +6 -1
- package/scripts/rank_signals.py +9 -0
- package/scripts/recompute.py +15 -5
- package/scripts/recovery.py +21 -15
- package/scripts/release.py +14 -26
- package/scripts/release_check.py +5 -25
- package/scripts/replay_eval.py +2 -2
- package/scripts/research_cli.py +40 -0
- package/scripts/research_notes.py +368 -0
- package/scripts/route.py +32 -70
- package/scripts/route_audit.py +259 -0
- package/scripts/route_combo.py +10 -4
- package/scripts/route_domains.py +150 -23
- package/scripts/route_lang.py +20 -7
- package/scripts/route_log.py +26 -9
- package/scripts/route_policy.py +85 -6
- package/scripts/route_telemetry_export.py +199 -0
- package/scripts/rrf_classic.py +5 -22
- package/scripts/search.py +2 -1
- package/scripts/search_attribution.py +33 -10
- package/scripts/search_entry.py +5 -1
- package/scripts/search_output.py +5 -4
- package/scripts/search_pipeline.py +12 -0
- package/scripts/search_rank.py +21 -11
- package/scripts/semantic_evidence.py +375 -168
- package/scripts/settings_page.py +3 -3
- package/scripts/social_engines/xiaohongshu_engine.py +2 -1
- package/scripts/social_engines/zhihu_engine.py +251 -43
- package/scripts/sogou_weixin_browser.py +5 -6
- package/scripts/source_audit.py +2 -2
- package/scripts/source_ledger.py +2 -15
- package/scripts/source_selection.py +45 -20
- package/scripts/straggler_policy.py +1 -2
- package/scripts/sync_backends.py +17 -0
- package/scripts/tfidf_router.py +23 -11
- package/scripts/time_utils.py +54 -1
- package/scripts/train.py +68 -2
- package/scripts/usage_log.py +26 -1
- package/sub-skills/argo-wide-research/SKILL.md +68 -0
- package/sub-skills/ego-search/SKILL.md +1 -1
- package/sub-skills/local-seek/scripts/seek_fts.py +58 -3
- package/scripts/caliber_dedupe.py +0 -66
- package/scripts/engines_builders_batch16.py +0 -13
- package/scripts/health_probe.py +0 -253
- package/scripts/social_engines/twitter_engine.py +0 -514
- package/scripts/sync_installs.py +0 -29
package/scripts/engines_base.py
CHANGED
|
@@ -14,6 +14,7 @@ import subprocess
|
|
|
14
14
|
import sys
|
|
15
15
|
import threading
|
|
16
16
|
import engine_states as _st # 失败归因词表唯一真源
|
|
17
|
+
from engines_fields import _coerce_field # 字段取值原语真源在 engines_fields(无依赖底层),本模块复导出
|
|
17
18
|
|
|
18
19
|
import serp_kill_log # noqa: E402 守卫接线+误杀账本(2026-10-10 拆出,stdlib 级轻量)
|
|
19
20
|
import time
|
|
@@ -196,11 +197,13 @@ def rank_score(base: float, rank: int) -> float:
|
|
|
196
197
|
return round(b / (1.0 + r * RANK_DECAY), 4)
|
|
197
198
|
|
|
198
199
|
|
|
199
|
-
def _run(cmd: list[str], timeout: float = 8, engine_name: str = "?"
|
|
200
|
+
def _run(cmd: list[str], timeout: float = 8, engine_name: str = "?",
|
|
201
|
+
env: dict[str, str] | None = None) -> str:
|
|
200
202
|
"""执行命令,超时/异常不抛。"""
|
|
201
203
|
try:
|
|
202
204
|
r = subprocess.run(cmd, capture_output=True, text=True,
|
|
203
|
-
encoding="utf-8", errors="replace",
|
|
205
|
+
encoding="utf-8", errors="replace",
|
|
206
|
+
timeout=timeout, env=env)
|
|
204
207
|
if r.returncode == 0:
|
|
205
208
|
return r.stdout
|
|
206
209
|
tail = (r.stderr or "").strip()[:200]
|
|
@@ -233,10 +236,10 @@ def _proc_uuid() -> str:
|
|
|
233
236
|
return _PROC_UUID
|
|
234
237
|
|
|
235
238
|
|
|
236
|
-
def _resolve(template: list[str] | str, query: str, n: int, **extra: Any) -> list[str] | str:
|
|
239
|
+
def _resolve(template: list[str] | str, query: str, n: int, allowed_env: frozenset[str] | set[str] | None = None, **extra: Any) -> list[str] | str:
|
|
237
240
|
"""替换模板占位符。"""
|
|
238
241
|
if isinstance(template, list):
|
|
239
|
-
return [_resolve(item, query, n, **extra) for item in template]
|
|
242
|
+
return [_resolve(item, query, n, allowed_env=allowed_env, **extra) for item in template]
|
|
240
243
|
s = template.replace("{query_quoted}", urllib.parse.quote(str(query))).replace("{query}", query).replace("{n}", str(n))
|
|
241
244
|
if "{query_slug}" in s:
|
|
242
245
|
_slug = next((_t for _tok in re.split(r"[\s,,。/?]+", str(query)) if (_t := _tok.strip().lower()) and re.fullmatch(r"[a-z][a-z0-9.\-_]{1,30}", _t) and not any(_w in _t for _w in ("生命周期", "支持到", "eol", "support", "lifecycle", "什么时候", "停更"))), "")
|
|
@@ -252,16 +255,10 @@ def _resolve(template: list[str] | str, query: str, n: int, **extra: Any) -> lis
|
|
|
252
255
|
# 历史兼容名):os.environ 优先 + ~/.config/argo/env 热读保底
|
|
253
256
|
# (密钥轮换改文件即生效,无需重启)。
|
|
254
257
|
try:
|
|
255
|
-
from engine_env import
|
|
256
|
-
return
|
|
257
|
-
r"\{([A-Z_][A-Z0-9_]*)\}",
|
|
258
|
-
lambda m: _get_env(
|
|
259
|
-
_PA.get(m.group(1), [f"ARGO_{m.group(1)}", m.group(1)]), ""
|
|
260
|
-
),
|
|
261
|
-
s,
|
|
262
|
-
)
|
|
258
|
+
from engine_env import resolve_env_placeholders
|
|
259
|
+
return resolve_env_placeholders(s, allowed_env=allowed_env)
|
|
263
260
|
except ImportError:
|
|
264
|
-
return re.sub(r"\{([A-Z_][A-Z0-9_]*)\}", lambda m: os.environ.get(m.group(1), ""), s)
|
|
261
|
+
return re.sub(r"\{([A-Z_][A-Z0-9_]*)\}", lambda m: os.environ.get(m.group(1), "") if (allowed_env is None or m.group(1) in allowed_env) else "", s)
|
|
265
262
|
|
|
266
263
|
|
|
267
264
|
_AUTH_PREFIXES = ("Bearer", "token", "Basic", "Key", "Api-Key", "X-Key", "Secret", "Appid")
|
|
@@ -305,22 +302,6 @@ def _get_path(obj: Any, path: str) -> Any:
|
|
|
305
302
|
return cur
|
|
306
303
|
|
|
307
304
|
|
|
308
|
-
def _coerce_field(val: Any, *, max_len: int | None = None) -> str:
|
|
309
|
-
"""把 API 字段压成字符串:list 取首项、dict 丢弃、其余 str。"""
|
|
310
|
-
if val is None:
|
|
311
|
-
return ""
|
|
312
|
-
if isinstance(val, list):
|
|
313
|
-
if not val:
|
|
314
|
-
return ""
|
|
315
|
-
val = val[0]
|
|
316
|
-
if isinstance(val, dict):
|
|
317
|
-
return ""
|
|
318
|
-
s = str(val).strip()
|
|
319
|
-
if max_len is not None and len(s) > max_len:
|
|
320
|
-
return s[:max_len]
|
|
321
|
-
return s
|
|
322
|
-
|
|
323
|
-
|
|
324
305
|
def _format_url_template(template: str, item: dict) -> str:
|
|
325
306
|
"""委托 engines_parsers(声明式字段映射的 URL 模板能力归属解析层)。"""
|
|
326
307
|
from engines_parsers import _format_url_template as _impl
|
|
@@ -342,14 +323,16 @@ def _make_field_parser(path: str, fields: dict[str, str], url_template: str | No
|
|
|
342
323
|
def _build_cli_engine(spec: dict[str, Any]) -> Any:
|
|
343
324
|
cmd_template = spec.get("cmd", [])
|
|
344
325
|
search_args = spec.get("search_args", [])
|
|
345
|
-
env_overrides = spec.get("env", {})
|
|
346
326
|
output_format = spec.get("output_format", "") # "yaml" | ""(JSON/文本自动)
|
|
347
327
|
filter_args = spec.get("filter_args", {}) # {kwarg: [参数模板...]},kwargs 携带时追加
|
|
328
|
+
eng = spec.get("_name", "cli")
|
|
329
|
+
from engine_env import allowed_placeholders_for, build_child_env
|
|
330
|
+
_allowed = allowed_placeholders_for(eng, spec)
|
|
348
331
|
|
|
349
332
|
@safe_search
|
|
350
333
|
def _engine(query: str, n: int = 5, timeout: float = 8, mode: str = "fast", **kwargs) -> list[dict[str, Any]]:
|
|
351
|
-
cmd = _resolve(cmd_template, query, n, mode=mode, **kwargs)
|
|
352
|
-
args = _resolve(search_args, query, n, mode=mode, **kwargs)
|
|
334
|
+
cmd = _resolve(cmd_template, query, n, allowed_env=_allowed, mode=mode, **kwargs)
|
|
335
|
+
args = _resolve(search_args, query, n, allowed_env=_allowed, mode=mode, **kwargs)
|
|
353
336
|
if not cmd:
|
|
354
337
|
return []
|
|
355
338
|
# 跨平台解释器:优先 sys.executable(bin/argo 已验证它带 PyYAML);
|
|
@@ -359,12 +342,10 @@ def _build_cli_engine(spec: dict[str, Any]) -> Any:
|
|
|
359
342
|
cmd[0] = sys.executable or shutil.which("python3") or shutil.which("python")
|
|
360
343
|
for key, tmpl in filter_args.items():
|
|
361
344
|
if kwargs.get(key) not in (None, ""):
|
|
362
|
-
args += _resolve(tmpl, query, n, mode=mode, **kwargs)
|
|
363
|
-
env = os.environ.copy()
|
|
364
|
-
env.update(env_overrides)
|
|
345
|
+
args += _resolve(tmpl, query, n, allowed_env=_allowed, mode=mode, **kwargs)
|
|
365
346
|
return _apply_url_kind(
|
|
366
|
-
_parse_text_output(_run(cmd + args, timeout=timeout, engine_name=
|
|
367
|
-
|
|
347
|
+
_parse_text_output(_run(cmd + args, timeout=timeout, engine_name=eng, env=build_child_env(eng, spec)),
|
|
348
|
+
eng, output_format=output_format, n=n),
|
|
368
349
|
spec)
|
|
369
350
|
return _engine
|
|
370
351
|
|
|
@@ -397,6 +378,8 @@ def _build_http_engine(spec: dict[str, Any]) -> Any:
|
|
|
397
378
|
is_get = spec.get("method", "GET") == "GET"
|
|
398
379
|
body_template = spec.get("body", {})
|
|
399
380
|
eng = spec.get("_name", "")
|
|
381
|
+
from engine_env import allowed_placeholders_for, env_flag
|
|
382
|
+
_allowed = allowed_placeholders_for(eng, spec)
|
|
400
383
|
# spec 显式节流覆盖(max_concurrency / min_interval_ms),声明即契约
|
|
401
384
|
if spec.get("max_concurrency") is not None or \
|
|
402
385
|
spec.get("min_interval_ms") is not None:
|
|
@@ -414,7 +397,7 @@ def _build_http_engine(spec: dict[str, Any]) -> Any:
|
|
|
414
397
|
import urllib.parse as up
|
|
415
398
|
|
|
416
399
|
if is_get:
|
|
417
|
-
resolved_url = _resolve(url_template, query, n, **kwargs)
|
|
400
|
+
resolved_url = _resolve(url_template, query, n, allowed_env=_allowed, **kwargs)
|
|
418
401
|
parts: list[str] = []
|
|
419
402
|
if query_param: # 空字符串表示该 API 不用查询参数名(仅 extra_params)
|
|
420
403
|
parts.append(f"{query_param}={up.quote(query)}")
|
|
@@ -424,7 +407,7 @@ def _build_http_engine(spec: dict[str, Any]) -> Any:
|
|
|
424
407
|
# 语言参数动态化(v2.7):按查询主语言覆盖静态 setlang/hl/lang/mkt
|
|
425
408
|
if k in ("setlang", "hl", "lang", "uselang", "mkt"):
|
|
426
409
|
v = _lang_param(k, query) or v
|
|
427
|
-
parts.append(f"{k}={up.quote(_resolve(str(v), query, n, **kwargs))}")
|
|
410
|
+
parts.append(f"{k}={up.quote(_resolve(str(v), query, n, allowed_env=_allowed, **kwargs))}")
|
|
428
411
|
if parts:
|
|
429
412
|
separator = "&" if "?" in resolved_url else "?"
|
|
430
413
|
full_url = resolved_url + separator + "&".join(parts)
|
|
@@ -432,7 +415,7 @@ def _build_http_engine(spec: dict[str, Any]) -> Any:
|
|
|
432
415
|
full_url = resolved_url
|
|
433
416
|
resolved_headers = {
|
|
434
417
|
k: v for k, v in (
|
|
435
|
-
(k, _resolve(v, query, n, **kwargs))
|
|
418
|
+
(k, _resolve(v, query, n, allowed_env=_allowed, **kwargs))
|
|
436
419
|
for k, v in headers.items()
|
|
437
420
|
) if _header_meaningful(v) # 过滤空/认证前缀残留头(未配置的 {ENV} 不发送)
|
|
438
421
|
}
|
|
@@ -445,7 +428,7 @@ def _build_http_engine(spec: dict[str, Any]) -> Any:
|
|
|
445
428
|
else:
|
|
446
429
|
body: dict[str, Any] = {}
|
|
447
430
|
for k, v in body_template.items():
|
|
448
|
-
resolved = _resolve(str(v), query, n, **kwargs)
|
|
431
|
+
resolved = _resolve(str(v), query, n, allowed_env=_allowed, **kwargs)
|
|
449
432
|
if k == "search_depth":
|
|
450
433
|
body[k] = {"fast": "fast", "balanced": "basic", "deep": "advanced", "basic": "basic", "advanced": "advanced", "ultra-fast": "ultra-fast"}.get(str(depth), resolved or "basic")
|
|
451
434
|
elif resolved.lower() == "true":
|
|
@@ -461,19 +444,19 @@ def _build_http_engine(spec: dict[str, Any]) -> Any:
|
|
|
461
444
|
except ValueError:
|
|
462
445
|
body[k] = resolved
|
|
463
446
|
# 与 GET 路径保持一致:过滤空/认证前缀残留头;POST 默认走 HttpClient 连接池
|
|
464
|
-
|
|
447
|
+
resolved_url = _resolve(url_template, query, n, allowed_env=_allowed, **kwargs)
|
|
448
|
+
resolved_headers = {k: v for k, v in ((k, _resolve(v, query, n, allowed_env=_allowed, **kwargs))
|
|
465
449
|
for k, v in headers.items()) if _header_meaningful(v)}
|
|
466
|
-
from engine_env import env_flag
|
|
467
450
|
import urllib.request as _urllib_request
|
|
468
451
|
if env_flag("ARGO_ENGINE_HTTP_CLIENT") and getattr(_urllib_request.urlopen, "__module__", "") == "urllib.request":
|
|
469
452
|
from http_client import HttpClient
|
|
470
|
-
resp = HttpClient(timeout=to, max_retries=0, jitter=False).post(
|
|
453
|
+
resp = HttpClient(timeout=to, max_retries=0, jitter=False).post(resolved_url, body=body, extra_headers=resolved_headers, engine=eng)
|
|
471
454
|
raw = (resp.get("text") or "") if resp.get("status") == 200 else ""
|
|
472
455
|
if not raw:
|
|
473
456
|
_note_http_failure(eng, resp.get("status") or 0, resp.get("text") or resp.get("error", ""))
|
|
474
457
|
return []
|
|
475
458
|
else:
|
|
476
|
-
req = _urllib_request.Request(
|
|
459
|
+
req = _urllib_request.Request(resolved_url, data=json.dumps(body).encode("utf-8"), headers=resolved_headers)
|
|
477
460
|
try:
|
|
478
461
|
with http_open(req, timeout=to, engine=eng) as resp:
|
|
479
462
|
raw = resp.read().decode("utf-8")
|
|
@@ -801,7 +784,7 @@ def _parse_http_payload(raw: str, fmt: str, eng: str, n: int,
|
|
|
801
784
|
templates={
|
|
802
785
|
# 多字段拼接模板(2026-11-10):声明后覆盖同名单字段映射,
|
|
803
786
|
# 把原 builder 的「tombstone · 授权 CC0」这类拼接变成声明式能力。
|
|
804
|
-
k: output_map.get(k) for k in ("item_title_template", "item_summary_template")
|
|
787
|
+
k: output_map.get(k) for k in ("item_title_template", "item_summary_template", "item_image_template")
|
|
805
788
|
},
|
|
806
789
|
url_item_template=output_map.get("item_url_template"))(data)
|
|
807
790
|
# spec 级授权常量:授权不随条目变化的源(如 NASA 公版)在 spec 上写一次
|
|
@@ -812,15 +795,14 @@ def _parse_http_payload(raw: str, fmt: str, eng: str, n: int,
|
|
|
812
795
|
r["published_at"] = _normalize_epoch(r["published_at"])
|
|
813
796
|
if _lic and r.get("image_url"):
|
|
814
797
|
r.setdefault("image_license", _lic)
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
if
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
r["snippet"] = sn
|
|
798
|
+
for _fk, _cap in (("title", 500), ("snippet", 300)):
|
|
799
|
+
_fv = r.get(_fk)
|
|
800
|
+
if isinstance(_fv, str):
|
|
801
|
+
if _TAGISH_RE.search(_fv):
|
|
802
|
+
_fv = _TAGISH_RE.sub("", _fv)
|
|
803
|
+
if "&" in _fv:
|
|
804
|
+
_fv = _htmllib.unescape(_fv)
|
|
805
|
+
r[_fk] = (_fv.strip() if _fk == "title" else _fv)[:_cap]
|
|
824
806
|
# 图片元数据收尾(尺寸转 int / 许可归一 / 商用判据)——落在这个共同
|
|
825
807
|
# 出口而不是各 parser 里:图源有三条产出路径(声明式 output_map、
|
|
826
808
|
# 自定义 builder、通用兜底),只覆盖一条会让契约对一半结果生效。
|
|
@@ -932,6 +914,8 @@ def _build_html_engine(spec: dict[str, Any]) -> Any:
|
|
|
932
914
|
timeout = spec.get("timeout", 8)
|
|
933
915
|
extra_params = spec.get("extra_params", {})
|
|
934
916
|
engine_name = spec.get("_name", "html")
|
|
917
|
+
from engine_env import allowed_placeholders_for
|
|
918
|
+
_allowed = allowed_placeholders_for(engine_name, spec)
|
|
935
919
|
# spec 显式节流覆盖(max_concurrency / min_interval_ms),声明即契约
|
|
936
920
|
if spec.get("max_concurrency") is not None or \
|
|
937
921
|
spec.get("min_interval_ms") is not None:
|
|
@@ -959,17 +943,17 @@ def _build_html_engine(spec: dict[str, Any]) -> Any:
|
|
|
959
943
|
def _engine(query: str, n: int = 5, _timeout: float | None = None, **kwargs) -> list[dict[str, Any]]:
|
|
960
944
|
import urllib.parse as up
|
|
961
945
|
to = _timeout or timeout
|
|
962
|
-
resolved_url = _resolve(url_template, query, n)
|
|
946
|
+
resolved_url = _resolve(url_template, query, n, allowed_env=_allowed)
|
|
963
947
|
separator = "&" if "?" in resolved_url else "?"
|
|
964
948
|
full_url = f"{resolved_url}{separator}{query_param}={up.quote(query)}"
|
|
965
949
|
for k, v in extra_params.items():
|
|
966
950
|
# 语言参数动态化:按查询主语言覆盖 setlang/hl/lang/mkt(此前漏 mkt)
|
|
967
951
|
if k in ("setlang", "hl", "lang", "uselang", "mkt"):
|
|
968
952
|
v = _lang_param(k, query) or v
|
|
969
|
-
full_url += f"&{k}={up.quote(_resolve(str(v), query, n, **kwargs))}" # **kwargs 必传(声明式路径 :441 传了):否则 {MODE}/{DEPTH} 带字面量花括号进 URL
|
|
953
|
+
full_url += f"&{k}={up.quote(_resolve(str(v), query, n, allowed_env=_allowed, **kwargs))}" # **kwargs 必传(声明式路径 :441 传了):否则 {MODE}/{DEPTH} 带字面量花括号进 URL
|
|
970
954
|
resolved_headers = {
|
|
971
955
|
k: v for k, v in (
|
|
972
|
-
(k, _resolve(v, query, n))
|
|
956
|
+
(k, _resolve(v, query, n, allowed_env=_allowed))
|
|
973
957
|
for k, v in headers.items()
|
|
974
958
|
) if _header_meaningful(v) # 过滤空/认证前缀残留头(未配置的 {ENV} 不发送)
|
|
975
959
|
}
|
|
@@ -47,10 +47,7 @@ from engines_builders_cn import (
|
|
|
47
47
|
_build_cls_telegraph_engine,
|
|
48
48
|
_build_em_global_news_engine,
|
|
49
49
|
_build_eastmoney_engine,
|
|
50
|
-
_build_itotii_engine,
|
|
51
50
|
_build_baidu_hot_engine,
|
|
52
|
-
_build_toutiao_hot_engine,
|
|
53
|
-
_build_bilibili_hot_engine,
|
|
54
51
|
_build_zhihu_global_engine,
|
|
55
52
|
_build_zhihu_user_engine,
|
|
56
53
|
_build_bocha_engine,
|
|
@@ -64,8 +61,6 @@ from engines_builders_cn import (
|
|
|
64
61
|
_build_people_daily_engine,
|
|
65
62
|
_build_flk_law_engine,
|
|
66
63
|
_build_wikisource_engine,
|
|
67
|
-
_build_weibo_hot_engine,
|
|
68
|
-
_build_douyin_hot_engine,
|
|
69
64
|
_build_csdn_engine,
|
|
70
65
|
_build_wallstreetcn_engine,
|
|
71
66
|
_build_weather_cn_engine,
|
|
@@ -165,10 +160,6 @@ from engines_builders_intl import (
|
|
|
165
160
|
_build_google_news_engine,
|
|
166
161
|
_build_met_museum_engine,
|
|
167
162
|
)
|
|
168
|
-
# vam 与 wikimedia_commons 同属图源补强模块(batch11),不进 intl 组
|
|
169
|
-
from engines_builders_batch11 import (
|
|
170
|
-
_build_vam_engine,
|
|
171
|
-
)
|
|
172
163
|
from engines_builders_feeds import (
|
|
173
164
|
_build_rss_feed_engine,
|
|
174
165
|
)
|
|
@@ -200,14 +191,11 @@ __all__ = [
|
|
|
200
191
|
"_build_people_daily_engine",
|
|
201
192
|
"_build_flk_law_engine",
|
|
202
193
|
"_build_wikisource_engine",
|
|
203
|
-
"_build_weibo_hot_engine",
|
|
204
|
-
"_build_douyin_hot_engine",
|
|
205
194
|
"_build_csdn_engine",
|
|
206
195
|
"_build_wallstreetcn_engine",
|
|
207
196
|
"_build_weather_cn_engine",
|
|
208
197
|
"_build_google_news_engine",
|
|
209
198
|
"_build_met_museum_engine",
|
|
210
|
-
"_build_vam_engine",
|
|
211
199
|
"_build_google_scholar_engine",
|
|
212
200
|
"_build_v2ex_engine",
|
|
213
201
|
"_build_github_engine",
|
|
@@ -215,10 +203,7 @@ __all__ = [
|
|
|
215
203
|
"_build_cls_telegraph_engine",
|
|
216
204
|
"_build_em_global_news_engine",
|
|
217
205
|
"_build_eastmoney_engine",
|
|
218
|
-
"_build_itotii_engine",
|
|
219
206
|
"_build_baidu_hot_engine",
|
|
220
|
-
"_build_toutiao_hot_engine",
|
|
221
|
-
"_build_bilibili_hot_engine",
|
|
222
207
|
"_build_open_library_engine",
|
|
223
208
|
"_build_weread_engine",
|
|
224
209
|
"_build_douban_book_engine",
|