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.
- package/AGENTS.md +8 -6
- package/README.es.md +57 -813
- package/README.ja.md +56 -814
- package/README.ko.md +56 -812
- package/README.md +160 -754
- package/README.zh.md +152 -872
- package/SKILL.md +22 -23
- 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 +149 -6
- package/backends/engine_concept_vectors.json +1525 -1525
- package/backends/engine_registry.yaml +139 -30
- package/backends/quota_profiles.json +83 -3
- package/bin/argo +33 -17
- package/config.yaml +189 -33
- package/docs/ADDING_NEW_ENGINE.md +10 -0
- package/docs/ARGO_INTRO.md +1 -1
- package/docs/CHANGELOG.md +38 -0
- package/docs/ENGINE_CATALOG.md +102 -89
- package/docs/MCP_SETUP.md +10 -1
- package/docs/RELEASE_NOTES_v2.14.1.md +4 -4
- package/docs/RELEASE_NOTES_v2.15.0.md +50 -0
- package/docs/RELEASE_NOTES_v2.16.0.md +58 -0
- package/docs/RELEASING.md +1 -1
- package/engines/specs/ai_labs.yaml +89 -0
- package/engines/specs/archive_org.yaml +1 -1
- package/engines/specs/bilibili_hot.yaml +11 -1
- package/engines/specs/brave.yaml +3 -3
- package/engines/specs/carbon_intensity.yaml +1 -1
- package/engines/specs/cisa_alerts.yaml +40 -0
- package/engines/specs/cn_ai_news.yaml +10 -8
- package/engines/specs/crates.yaml +1 -1
- package/engines/specs/crossref.yaml +4 -2
- package/engines/specs/crt_sh.yaml +1 -1
- package/engines/specs/dblp.yaml +1 -1
- package/engines/specs/devto.yaml +1 -1
- package/engines/specs/digup.yaml +11 -6
- package/engines/specs/docker_hub.yaml +1 -1
- 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/europepmc.yaml +1 -1
- 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 +30 -7
- package/engines/specs/gbfs_nyc.yaml +1 -1
- package/engines/specs/gleif.yaml +1 -1
- package/engines/specs/gov_regulations.yaml +1 -1
- package/engines/specs/grepapp_mcp.yaml +62 -0
- package/engines/specs/guardian_rss.yaml +6 -4
- package/engines/specs/hf_datasets.yaml +1 -1
- package/engines/specs/huggingface.yaml +1 -1
- package/engines/specs/itotii.yaml +13 -1
- package/engines/specs/keenable.yaml +7 -1
- package/engines/specs/linux_do.yaml +63 -0
- package/engines/specs/lobsters.yaml +41 -0
- package/engines/specs/local_crossref.yaml +3 -1
- package/engines/specs/local_github.yaml +1 -1
- package/engines/specs/local_npm.yaml +6 -0
- package/engines/specs/local_openstreetmap.yaml +1 -1
- package/engines/specs/local_seek.yaml +6 -0
- package/engines/specs/maven.yaml +1 -1
- package/engines/specs/mdn.yaml +1 -1
- package/engines/specs/musicbrainz.yaml +1 -1
- package/engines/specs/nasa_images.yaml +1 -1
- package/engines/specs/nhtsa_vpic.yaml +6 -3
- package/engines/specs/npm.yaml +1 -1
- package/engines/specs/nuget.yaml +1 -1
- package/engines/specs/nvd.yaml +1 -1
- package/engines/specs/open_meteo.yaml +1 -1
- package/engines/specs/openalex.yaml +4 -2
- package/engines/specs/openreview.yaml +1 -1
- package/engines/specs/polymarket.yaml +1 -1
- package/engines/specs/redskill.yaml +2 -0
- package/engines/specs/searxng.yaml +4 -2
- package/engines/specs/sec_edgar.yaml +9 -4
- package/engines/specs/steam.yaml +1 -1
- 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/wikidata.yaml +1 -1
- package/engines/specs/wikipedia.yaml +1 -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_hot_app.yaml +1 -1
- package/engines/specs/zhihu_kb.yaml +18 -0
- package/engines/specs/zhihu_questions.yaml +19 -0
- package/package.json +4 -2
- package/packages/dsh-plugin/README.md +9 -14
- package/packages/dsh-plugin/dsh/client.js +481 -1037
- package/packages/dsh-plugin/dsh/diagnostics.js +71 -20
- package/packages/dsh-plugin/dsh/index.js +6 -0
- package/packages/dsh-plugin/dsh/runner.js +3 -1
- package/packages/dsh-plugin/dsh/workbench-client.js +796 -0
- package/packages/dsh-plugin/dsh/workbench-md.js +386 -0
- package/packages/dsh-plugin/dsh/workbench-suggestions.js +148 -0
- package/packages/dsh-plugin/dsh/workbench.js +966 -0
- package/packages/dsh-plugin/icon.svg +23 -0
- package/packages/dsh-plugin/package.json +10 -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/packages/dsh-plugin/test/workbench.test.js +92 -0
- package/scripts/adaptive.py +7 -1
- package/scripts/archive_run.py +112 -53
- package/scripts/argo_paths.py +42 -5
- package/scripts/badcase_ledger.py +117 -9
- package/scripts/build_concept_table.py +112 -55
- package/scripts/cache.py +6 -2
- package/scripts/caliber_isolation.py +60 -23
- package/scripts/circuit_breaker.py +72 -11
- package/scripts/cli_io.py +20 -2
- package/scripts/config_cache.py +44 -1
- package/scripts/daemon.py +151 -51
- package/scripts/dormant_ledger.py +23 -9
- package/scripts/engine_dispatch.py +8 -5
- package/scripts/engine_env.py +191 -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 +66 -61
- package/scripts/engines_builders.py +0 -15
- package/scripts/engines_builders_archive.py +4 -3
- package/scripts/engines_builders_batch10.py +346 -100
- package/scripts/engines_builders_batch11.py +4 -76
- package/scripts/engines_builders_batch13.py +4 -3
- package/scripts/engines_builders_batch14.py +2 -1
- package/scripts/engines_builders_batch15.py +2 -1
- package/scripts/engines_builders_batch9.py +16 -25
- package/scripts/engines_builders_cn.py +7 -201
- package/scripts/engines_builders_data.py +12 -11
- package/scripts/engines_builders_data_macro.py +5 -4
- package/scripts/engines_builders_dsh.py +2 -1
- package/scripts/engines_builders_feeds.py +76 -11
- package/scripts/engines_builders_finance.py +2 -1
- package/scripts/engines_builders_intl.py +18 -117
- package/scripts/engines_builders_media.py +59 -12
- package/scripts/engines_builders_pixiv.py +2 -16
- package/scripts/engines_builders_science.py +8 -7
- package/scripts/engines_builders_search.py +7 -14
- package/scripts/engines_builders_skill.py +2 -1
- package/scripts/engines_builders_tech.py +8 -17
- package/scripts/engines_builders_weather.py +241 -0
- package/scripts/engines_fields.py +91 -0
- package/scripts/engines_http.py +184 -0
- package/scripts/engines_mcp.py +405 -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 +19 -4
- package/scripts/extend_route_labels.py +6 -0
- package/scripts/fetch_jina.py +98 -0
- package/scripts/fetch_jsrun.py +15 -11
- package/scripts/fetch_v3.py +79 -120
- 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/image_vision/vision_probe +0 -0
- package/scripts/install.sh +2 -0
- package/scripts/link_source.py +65 -24
- package/scripts/local_seek_adapter.py +57 -17
- package/scripts/matrix_search_eval.py +8 -10
- package/scripts/mcp_handlers.py +53 -31
- package/scripts/mcp_handlers_surface.py +6 -18
- package/scripts/mcp_transport.py +10 -5
- package/scripts/min_version_scan.py +7 -3
- package/scripts/network_aware.py +7 -13
- package/scripts/numeric_verify.py +3 -2
- package/scripts/output_transparency.py +3 -0
- package/scripts/pre-commit +45 -43
- package/scripts/query_understanding.py +30 -6
- package/scripts/quota.py +36 -30
- package/scripts/rank_signals.py +9 -0
- package/scripts/recompute.py +15 -5
- package/scripts/recovery.py +38 -29
- package/scripts/recovery_runner.py +29 -10
- package/scripts/redskill/redskill_engine.py +2 -1
- 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 +40 -70
- package/scripts/route_audit.py +259 -0
- package/scripts/route_combo.py +21 -6
- 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 +53 -10
- package/scripts/search_entry.py +32 -1
- package/scripts/search_output.py +23 -11
- package/scripts/search_pipeline.py +15 -3
- package/scripts/search_rank.py +21 -11
- package/scripts/semantic_evidence.py +394 -178
- package/scripts/serp_guard.py +13 -1
- package/scripts/settings_page.py +4 -3
- package/scripts/single_flight.py +1 -1
- package/scripts/social_engines/hackernews_engine.py +2 -1
- package/scripts/social_engines/reddit_engine.py +2 -1
- package/scripts/social_engines/xiaohongshu_engine.py +2 -1
- package/scripts/social_engines/zhihu_engine.py +252 -43
- package/scripts/sogou_weixin_browser.py +5 -6
- package/scripts/source_audit.py +44 -9
- 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 +50 -10
- package/scripts/watch.py +3 -3
- package/scripts/zhihu_quota.py +2 -1
- package/sub-skills/argo-wide-research/SKILL.md +70 -0
- package/sub-skills/ego-search/{SKILL.md → README.md} +15 -47
- package/sub-skills/ego-search/scripts/ego_search.py +13 -4
- package/sub-skills/js-run/{SKILL.md → README.md} +3 -20
- package/sub-skills/local-search/{SKILL.md → README.md} +3 -8
- package/sub-skills/local-search/engine_registry.py +32 -7
- package/sub-skills/local-seek/SKILL.md +20 -22
- 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/evidence.py
CHANGED
|
@@ -696,6 +696,17 @@ def compute_credibility(
|
|
|
696
696
|
snippet = r.get("snippet", "") or ""
|
|
697
697
|
|
|
698
698
|
auth = score_authority(url, source, query)
|
|
699
|
+
# 方案C(upstream_authority 只透传不赋权):排序层已拿到的上游权威档
|
|
700
|
+
# (zhihu builder 解析 AuthorityLevel / spec output_map 的
|
|
701
|
+
# item_upstream_authority)原样挂到 credibility.authority.upstream_level,
|
|
702
|
+
# 供取证侧与研报引用;不参与 selection/final 计算——上游档只补充
|
|
703
|
+
# 上下文,不替代本仓基于 URL/域名的评分。无上游档则不加键(不编造)。
|
|
704
|
+
_upstream = r.get("upstream_authority")
|
|
705
|
+
if _upstream is None or _upstream == "":
|
|
706
|
+
_upstream = r.get("authority_level")
|
|
707
|
+
if _upstream is not None and _upstream != "":
|
|
708
|
+
auth = dict(auth)
|
|
709
|
+
auth["upstream_level"] = _upstream
|
|
699
710
|
fresh = score_freshness(r, query_time)
|
|
700
711
|
density = score_evidence_density(snippet, title)
|
|
701
712
|
|
|
@@ -838,6 +849,8 @@ def main():
|
|
|
838
849
|
flag_s = ",".join(flags) if flags else "-"
|
|
839
850
|
print(f"{level} [{c['final']:.2f}] sel={c['selection']:.2f} abs={c['absorption']:.2f} [{flag_s}] {r['title'][:48]}")
|
|
840
851
|
print(f" 权威:{c['authority']['score']:.2f} ({c['authority']['reason']})")
|
|
852
|
+
if c["authority"].get("upstream_level") is not None:
|
|
853
|
+
print(f" 上游档:{c['authority']['upstream_level']}(upstream_authority 只透传)")
|
|
841
854
|
print(f" 时效:{c['freshness']['score']:.2f} ({c['freshness']['reason']})")
|
|
842
855
|
print()
|
|
843
856
|
|
package/scripts/evidence_loop.py
CHANGED
|
@@ -45,6 +45,16 @@ def _log(message: str) -> None:
|
|
|
45
45
|
# timing.elapsed_ms 里只看到 1.2s。核验是「加分项」不是「必须项」:到点
|
|
46
46
|
# 未回来的 URL 进 pending(语义与 fetch 失败完全一致),已回来的照常回填。
|
|
47
47
|
# 默认 5s 高于典型核验 2.9s,只砍尾部;需要完整降级链时设 0。
|
|
48
|
+
#
|
|
49
|
+
# 2026-11-16:预算是够的,缺的是并发。实测 --verify 10 只能核到 2-4 条,
|
|
50
|
+
# 一开始以为是 5s 太短,把预算按 top_k 放大到 13.4s——受控 A/B(同批查询、
|
|
51
|
+
# 同一批 URL、每次独立证据缓存)显示核验 31→38 条(1.2x)却把耗时
|
|
52
|
+
# 25.0→42.2s(1.7x),每条核验成本 0.8→1.1s **上升 37%**,不划算,已回退。
|
|
53
|
+
# 真正的瓶颈是 max_workers=3:10 个 URL 排 3 个 worker,预算全花在排队上。
|
|
54
|
+
# 只把并发放到 6、预算维持 5s,三轮冷启动 A/B(每臂互不重叠的唯一 URL,
|
|
55
|
+
# 绕开证据缓存复用)实测:核验 15.0→23.0 条(1.5x)、耗时 25.0→24.5s
|
|
56
|
+
# (持平略降)、每条核验成本 1.67→1.06s(降 36%)。所以预算公式保持原样,
|
|
57
|
+
# 只放宽 worker 上限。
|
|
48
58
|
def _verify_budget_s() -> float:
|
|
49
59
|
try:
|
|
50
60
|
raw = os.environ.get("ARGO_VERIFY_BUDGET_S", "5") or "5"
|
|
@@ -557,10 +567,14 @@ def verify_results(results: list[dict[str, Any]],
|
|
|
557
567
|
if targets and budget_s > 0:
|
|
558
568
|
# 硬墙钟:到点就返回,未完成的 URL 进 pending,不 join 卡住的线程。
|
|
559
569
|
# 预算只约束「这次核验等多久」,不改单 URL 的降级链语义。
|
|
570
|
+
# worker 上限 6(原 3):核验是纯 I/O 等待,3 个 worker 装不下 10 个
|
|
571
|
+
# URL,预算全花在排队。实测同样 5s 预算下核验 15→23 条(1.5x)、
|
|
572
|
+
# 耗时持平(唯一 URL 三轮冷启动 A/B,数字以文件头记录为准)。
|
|
573
|
+
# 单 URL 自带 8s deadline,放宽 worker 不会放大最坏耗时。
|
|
560
574
|
from bounded_run import TaskError, run_bounded
|
|
561
575
|
finished, unfinished = run_bounded(
|
|
562
576
|
targets, _fetch_one, budget_s,
|
|
563
|
-
max_workers=min(len(targets),
|
|
577
|
+
max_workers=min(len(targets), 6))
|
|
564
578
|
for item, value in finished:
|
|
565
579
|
if isinstance(value, TaskError):
|
|
566
580
|
_log(f"verify fetch 任务异常 {item.get('url') or ''}: "
|
|
@@ -588,9 +602,10 @@ def verify_results(results: list[dict[str, Any]],
|
|
|
588
602
|
assess_substantive_discussion, enabled as _semantic_enabled,
|
|
589
603
|
)
|
|
590
604
|
if _semantic_enabled():
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
605
|
+
# 三级阶梯兜底:Gemini 默认 → JEV 备用 → 本地启发式最终兜底
|
|
606
|
+
support = assess_support(query, scored_inputs, allow_heuristic=True)
|
|
607
|
+
source_types = assess_source_types(scored_inputs, allow_heuristic=True)
|
|
608
|
+
substantive_map = assess_substantive_discussion(query, scored_inputs, allow_heuristic=True)
|
|
594
609
|
primary_count = 0
|
|
595
610
|
substantive_count = 0
|
|
596
611
|
passing_count = 0
|
|
@@ -138,6 +138,12 @@ COLLISION_ANCHORS: list[tuple[str, str, str, str]] = [
|
|
|
138
138
|
# v2.10.2:学术检索正例
|
|
139
139
|
("科研数据集 开放数据 下载", "dataset_search", "academic", "v2.10.2"),
|
|
140
140
|
("google scholar 学术论文 期刊", "scholar_search", "academic", "v2.10.2"),
|
|
141
|
+
# 外部审计 2026-11-16:QDII/外管局额度类查询此前掉进 chinese_general 用
|
|
142
|
+
# 通用源打(fund_query/financial_news 词表均无这些词),而 eastmoney 点名
|
|
143
|
+
# 实测 1.0s 5 条相关。额度/限额数据问法归 fund_query;法规解读问法让位
|
|
144
|
+
# financial_news(fund_query 的 QDII 款带同款 unless)。
|
|
145
|
+
("QDII 额度 外管局 最新限额", "fund_query", "factual", "audit-2026-11-16"),
|
|
146
|
+
("QDII 管理办法 解读", "financial_news", "factual", "audit-2026-11-16"),
|
|
141
147
|
]
|
|
142
148
|
|
|
143
149
|
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""fetch_jina.py — r.jina.ai 阅读器层(fetch_v3 第一级C)。
|
|
3
|
+
|
|
4
|
+
从 fetch_v3.py 拆出(2026-11-17):与 fetch_jsrun、fetch_render_tinyfish
|
|
5
|
+
同构,独立成模块让 fetch_v3 行数回到祖父文件上限内。本层只负责「请求 Jina
|
|
6
|
+
并解析出 markdown」,公网边界(is_public_host)由调用方保证。
|
|
7
|
+
|
|
8
|
+
定位:HTTP/TLS 直连全败后的免浏览器快速路径——jina 在远端渲染并返回
|
|
9
|
+
markdown,命中则免去 CDP 冷启动。有 Key 用 Key(ARGO_JINA_API_KEY),
|
|
10
|
+
无 Key 走免 Key 匿名档兜底。失败返回 None,由 fetch_v3 主链降级到
|
|
11
|
+
Parallel/Wayback/浏览器。
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
import re
|
|
17
|
+
import sys
|
|
18
|
+
from pathlib import Path
|
|
19
|
+
|
|
20
|
+
SCRIPT_DIR = Path(__file__).resolve().parent
|
|
21
|
+
if str(SCRIPT_DIR) not in sys.path:
|
|
22
|
+
sys.path.insert(0, str(SCRIPT_DIR))
|
|
23
|
+
|
|
24
|
+
import engine_states
|
|
25
|
+
from engine_env import env_flag, get_env
|
|
26
|
+
from engines_http import lazy_logger
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def enabled() -> bool:
|
|
30
|
+
"""r.jina.ai 阅读器级开关:ARGO_FETCH_JINA=0 关闭,默认开启。"""
|
|
31
|
+
return env_flag("ARGO_FETCH_JINA")
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def fetch(url: str, max_chars: int = 8000, timeout: float = 8.0) -> dict | None:
|
|
35
|
+
"""r.jina.ai 阅读器(有 Key 用 Key,无 Key 走免 Key 兜底)。
|
|
36
|
+
|
|
37
|
+
Key 档与免 Key 档的差异(2026-11-17 实测):免 Key 匿名池按 IP 信誉
|
|
38
|
+
间歇返回 401 AuthenticationRequiredError(bad IP reputation),同机
|
|
39
|
+
4 次请求 3 次被拒;带 ARGO_JINA_API_KEY 稳定 200、500 RPM。故优先带
|
|
40
|
+
Key,缺失时仍走匿名档兜底(有总比没有强,失败由上层降级)。
|
|
41
|
+
"""
|
|
42
|
+
import fetch_v3 # 延迟导入:复用 _make_result / _looks_like_markdown,避免循环引用
|
|
43
|
+
|
|
44
|
+
try:
|
|
45
|
+
from http_client import HttpClient
|
|
46
|
+
client = HttpClient(timeout=min(timeout, 10.0), max_retries=0,
|
|
47
|
+
jitter=False)
|
|
48
|
+
headers = {
|
|
49
|
+
"User-Agent": "argo-fetch-v3/1.0 (+local-research; jina-reader)",
|
|
50
|
+
"Accept": "text/plain",
|
|
51
|
+
# 显式声明返回格式,避免默认格式漂移(官方可选 markdown/html/text/...)
|
|
52
|
+
"X-Respond-With": "markdown",
|
|
53
|
+
# 远端渲染等待上限对齐本级超时(官方上限 180s),避免默认值白等
|
|
54
|
+
"X-Timeout": str(int(min(max(timeout, 1.0), 180.0))),
|
|
55
|
+
# 输出 token 预算:超预算会被 Jina 以 409 BudgetExceededError
|
|
56
|
+
# 拒绝(2026-11-17 实测:8000 字符的 openai 页实际需 5806 token,
|
|
57
|
+
# 比例约 0.73 token/字符,含 Title/URL/Published 等 frontmatter)。
|
|
58
|
+
# 按 max_chars * 1.5 留余量,下限 1024 防短页被误拒。
|
|
59
|
+
"X-Token-Budget": str(max(1024, int(max_chars * 1.5))),
|
|
60
|
+
}
|
|
61
|
+
api_key = get_env("ARGO_JINA_API_KEY").strip()
|
|
62
|
+
if api_key:
|
|
63
|
+
headers["Authorization"] = f"Bearer {api_key}"
|
|
64
|
+
resp = client.get(f"https://r.jina.ai/{url}", extra_headers=headers)
|
|
65
|
+
except Exception as e:
|
|
66
|
+
# 失败可见化:jina 是降级链一级,静默 return None 让故障无法归因
|
|
67
|
+
#(静默棘轮口径只数 Pass/Continue,return None 形态在此补日志)
|
|
68
|
+
lazy_logger("unified_search.fetch_jina").warning(
|
|
69
|
+
"jina reader 失败(%s),降级 Parallel/Wayback/浏览器", e)
|
|
70
|
+
return None
|
|
71
|
+
if resp.get("status", 0) != 200 or not resp.get("text"):
|
|
72
|
+
return None
|
|
73
|
+
raw = resp["text"]
|
|
74
|
+
title = ""
|
|
75
|
+
m = re.search(r"^Title:\s*(.+)$", raw[:2000], re.MULTILINE)
|
|
76
|
+
if m:
|
|
77
|
+
title = m.group(1).strip()[:200]
|
|
78
|
+
if "Markdown Content:" in raw:
|
|
79
|
+
raw = raw.split("Markdown Content:", 1)[1].lstrip()
|
|
80
|
+
if not fetch_v3._looks_like_markdown(raw):
|
|
81
|
+
return None
|
|
82
|
+
result = fetch_v3._make_result(url, "", max_chars,
|
|
83
|
+
engine_states.FETCH_JINA_READER)
|
|
84
|
+
result["content"] = raw[:max_chars]
|
|
85
|
+
result["length"] = len(result["content"])
|
|
86
|
+
result["title"] = title
|
|
87
|
+
# 额度可见化:Reader 响应头带 x-ratelimit-*(RPM 档)与 x-usage-tokens
|
|
88
|
+
# (本次消耗)。10M 免费 token 是共享钱包,落进结果便于观测消耗。
|
|
89
|
+
resp_headers = {str(k).lower(): v
|
|
90
|
+
for k, v in (resp.get("headers") or {}).items()}
|
|
91
|
+
quota = {k: v for k, v in resp_headers.items()
|
|
92
|
+
if k.startswith(("x-ratelimit", "x-usage"))}
|
|
93
|
+
if quota:
|
|
94
|
+
result["jina_quota"] = quota
|
|
95
|
+
remaining = resp_headers.get("x-ratelimit-remaining")
|
|
96
|
+
if remaining and str(remaining).strip().isdigit() and int(remaining) < 50:
|
|
97
|
+
result["jina_low_quota"] = True
|
|
98
|
+
return result
|
package/scripts/fetch_jsrun.py
CHANGED
|
@@ -21,20 +21,24 @@ def _jsrun_enabled() -> bool:
|
|
|
21
21
|
return env_flag("ARGO_FETCH_JSRUN")
|
|
22
22
|
|
|
23
23
|
|
|
24
|
+
_MINI_RACER_OK: bool | None = None
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def _mini_racer_available() -> bool:
|
|
28
|
+
"""一次性探测 py_mini_racer 是否就绪,缺依赖时 O(1) 短路。"""
|
|
29
|
+
global _MINI_RACER_OK
|
|
30
|
+
if _MINI_RACER_OK is None:
|
|
31
|
+
import importlib.util
|
|
32
|
+
_MINI_RACER_OK = importlib.util.find_spec("py_mini_racer") is not None
|
|
33
|
+
return _MINI_RACER_OK
|
|
34
|
+
|
|
35
|
+
|
|
24
36
|
def _jsrun_challenge_fetch(url: str, html: str, max_chars: int = 8000,
|
|
25
37
|
timeout: float = 8.0,
|
|
26
38
|
backoff_budget_s: float | None = None) -> dict:
|
|
27
|
-
"""用 js-run 执行挑战页 JS,尝试获取 clearance cookie 后重试请求。
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
由调用方降级到 tinyfish/CDP。
|
|
31
|
-
|
|
32
|
-
重试请求用 curl_cffi Chrome 指纹 impersonate(站点按 TLS 指纹风控,
|
|
33
|
-
裸 Python 指纹被静默拦截)。退避重试 3 次(间隔 5s/10s)。
|
|
34
|
-
`backoff_budget_s`(秒)给整段重试设墙钟上界:传入时退避睡眠与后续
|
|
35
|
-
尝试都不得越过它——此前 sleep(5)+sleep(10) 不受链级预算约束,cookie
|
|
36
|
-
拿到而三连败时可在 fetch 链内部多耗 ~30s(2026-10-06 审查定位)。
|
|
37
|
-
"""
|
|
39
|
+
"""用 js-run 执行挑战页 JS,尝试获取 clearance cookie 后重试请求。"""
|
|
40
|
+
if not html or not _mini_racer_available():
|
|
41
|
+
return {}
|
|
38
42
|
import re as _re
|
|
39
43
|
import time as _time
|
|
40
44
|
|
package/scripts/fetch_v3.py
CHANGED
|
@@ -32,11 +32,13 @@ TLS 指纹伪造层(第一级B):
|
|
|
32
32
|
|
|
33
33
|
from __future__ import annotations
|
|
34
34
|
|
|
35
|
+
import atexit
|
|
35
36
|
import json
|
|
36
37
|
import os
|
|
37
38
|
import re
|
|
38
39
|
import signal
|
|
39
40
|
import sys
|
|
41
|
+
import threading
|
|
40
42
|
import time
|
|
41
43
|
import traceback
|
|
42
44
|
import urllib.parse
|
|
@@ -54,7 +56,9 @@ if SCRIPT_DIR not in sys.path:
|
|
|
54
56
|
# 渲染层(第二级A):TinyFish 直连渲染,独立模块以保持本文件聚焦主链调度;
|
|
55
57
|
# engine_states 是状态词表唯一真源(2026-11-09 收口)
|
|
56
58
|
import fetch_render_tinyfish as _render_tinyfish
|
|
59
|
+
import fetch_jina as _fetch_jina
|
|
57
60
|
import engine_states
|
|
61
|
+
from except_sets import IO_BENIGN, OPT_IMPORT, SHAPE_BENIGN # 收窄词汇表(2026-11-13 裸吞收口)
|
|
58
62
|
|
|
59
63
|
# 解码统一入口(2026-10-26,charset 是只依赖 re 的叶子模块,顶层导入无负担):
|
|
60
64
|
# urllib 兜底车道与主链共享「头声明 > meta 嗅探 > 猜测链」,GBK 老站不再满屏 U+FFFD
|
|
@@ -70,7 +74,7 @@ import fetch_quality as _quality
|
|
|
70
74
|
# 本地状态目录唯一来源(env ARGO_STATE_DIR → config cache.db_path 父目录 → 旧路径)
|
|
71
75
|
import argo_paths as _paths
|
|
72
76
|
from net_proxy import open_url # 出口调度唯一入口(issue #13 同类修复)
|
|
73
|
-
from engine_env import env_flag #
|
|
77
|
+
from engine_env import env_flag, get_env # env_flag 判开关;get_env 读密钥(os.environ 优先,env 文件热读保底)
|
|
74
78
|
from cli_io import dumps
|
|
75
79
|
from fetch_jsrun import _jsrun_challenge_fetch, _jsrun_enabled # js-run 轻量车道(拆出独立模块)
|
|
76
80
|
|
|
@@ -134,12 +138,12 @@ def extract_content(html: str, max_chars: int = 8000) -> tuple[str, str]:
|
|
|
134
138
|
content, title = extract_readability(html, max_chars=max_chars)
|
|
135
139
|
if content.strip():
|
|
136
140
|
return _cut(content, max_chars), title.strip()
|
|
137
|
-
except
|
|
141
|
+
except OPT_IMPORT + SHAPE_BENIGN:
|
|
138
142
|
pass
|
|
139
143
|
ext = ContentExtractor()
|
|
140
144
|
try:
|
|
141
145
|
ext.feed(html)
|
|
142
|
-
except
|
|
146
|
+
except SHAPE_BENIGN:
|
|
143
147
|
pass
|
|
144
148
|
ext._blocks.sort(key=lambda x: x[0], reverse=True)
|
|
145
149
|
content = "\n\n".join(text for _, text in ext._blocks[:10])
|
|
@@ -499,7 +503,7 @@ def _md_variant_fetch(url: str, max_chars: int = 8000,
|
|
|
499
503
|
"User-Agent": "argo-fetch-v3/1.0 (+local-research; md-variant)",
|
|
500
504
|
"Accept": "text/markdown, text/plain;q=0.9, */*;q=0.8",
|
|
501
505
|
})
|
|
502
|
-
except
|
|
506
|
+
except OPT_IMPORT + IO_BENIGN:
|
|
503
507
|
continue
|
|
504
508
|
if resp.get("status", 0) != 200 or not resp.get("text"):
|
|
505
509
|
continue
|
|
@@ -548,11 +552,8 @@ def _mobile_first_host(url: str) -> bool:
|
|
|
548
552
|
|
|
549
553
|
|
|
550
554
|
# ─── 身份记忆(per-host 成功档位,跨进程小文件)─────────────────────────────
|
|
551
|
-
#
|
|
552
|
-
# 首次访问未知分流站:桌面失败 → 移动成功(2 次触碰);记忆生效后(TTL 24h)
|
|
553
|
-
# 直接移动首发(1 次触碰)。实测依据:抖音类站点按 IP 递进限速,请求节奏比
|
|
554
|
-
# 身份选择重要一个数量级,省掉的每次试错都是真实的封禁风险。
|
|
555
555
|
_IDENTITY_TTL = 86400
|
|
556
|
+
_identity_lock = threading.Lock()
|
|
556
557
|
|
|
557
558
|
|
|
558
559
|
def _identity_path() -> str:
|
|
@@ -560,18 +561,11 @@ def _identity_path() -> str:
|
|
|
560
561
|
patched = globals().get("_IDENTITY_PATH")
|
|
561
562
|
if patched is not None:
|
|
562
563
|
return patched
|
|
563
|
-
return os.environ.get(
|
|
564
|
-
"ARGO_IDENTITY_MEMORY",
|
|
565
|
-
str(_paths.state_path("fetch-identity.json")))
|
|
564
|
+
return os.environ.get("ARGO_IDENTITY_MEMORY", str(_paths.state_path("fetch-identity.json")))
|
|
566
565
|
|
|
567
566
|
|
|
568
567
|
def __getattr__(name: str):
|
|
569
|
-
"""`_IDENTITY_PATH` 每次访问按当前 ARGO_IDENTITY_MEMORY 解析(PEP 562)。
|
|
570
|
-
|
|
571
|
-
290d3d8 同口径:状态根在导入后被改写是常态(测试临时目录、多工作树)。
|
|
572
|
-
模块内裸名查找不触发本函数(LOAD_GLOBAL 语义),函数体一律走
|
|
573
|
-
_identity_path();这里只维持外部属性访问与 monkeypatch 契约。
|
|
574
|
-
"""
|
|
568
|
+
"""`_IDENTITY_PATH` 每次访问按当前 ARGO_IDENTITY_MEMORY 解析(PEP 562)。"""
|
|
575
569
|
if name == "_IDENTITY_PATH":
|
|
576
570
|
return _identity_path()
|
|
577
571
|
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
|
@@ -581,60 +575,67 @@ _identity_mem: dict[str, float] = {}
|
|
|
581
575
|
_identity_loaded = False
|
|
582
576
|
_identity_dirty = False
|
|
583
577
|
_identity_last_flush = 0.0
|
|
584
|
-
_IDENTITY_FLUSH_INTERVAL = 30.0
|
|
578
|
+
_IDENTITY_FLUSH_INTERVAL = 30.0
|
|
579
|
+
_identity_atexit_registered = False
|
|
585
580
|
|
|
586
581
|
|
|
587
|
-
def
|
|
582
|
+
def _identity_load_locked() -> None:
|
|
588
583
|
global _identity_loaded, _identity_mem
|
|
589
584
|
if _identity_loaded:
|
|
590
585
|
return
|
|
591
586
|
_identity_loaded = True
|
|
592
587
|
try:
|
|
593
|
-
|
|
594
|
-
raw = json.load(f)
|
|
588
|
+
raw = json.loads(Path(_identity_path()).read_text(encoding="utf-8"))
|
|
595
589
|
now = time.time()
|
|
596
|
-
|
|
597
|
-
for h, t in raw.items():
|
|
598
|
-
try:
|
|
599
|
-
exp = float(t)
|
|
600
|
-
if exp > now:
|
|
601
|
-
mem[str(h)] = exp
|
|
602
|
-
except (TypeError, ValueError):
|
|
603
|
-
continue # 单条脏数据不拖垮整表(旧版本/手改字段)
|
|
604
|
-
_identity_mem = mem
|
|
590
|
+
_identity_mem = {str(h): float(t) for h, t in raw.items() if isinstance(t, (int, float)) and float(t) > now}
|
|
605
591
|
except Exception:
|
|
606
592
|
_identity_mem = {}
|
|
607
593
|
|
|
608
594
|
|
|
609
|
-
def
|
|
610
|
-
"""记录「该 host 移动端身份成功过」,最多每 30s 写一次文件。失败静默(纯增益层)。"""
|
|
595
|
+
def _identity_flush() -> None:
|
|
611
596
|
global _identity_dirty, _identity_last_flush
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
_identity_mem[host] = time.time() + _IDENTITY_TTL
|
|
618
|
-
_identity_dirty = True
|
|
619
|
-
now = time.monotonic()
|
|
620
|
-
if _identity_last_flush > 0.0 and now - _identity_last_flush < _IDENTITY_FLUSH_INTERVAL:
|
|
621
|
-
return
|
|
622
|
-
_identity_last_flush = now
|
|
597
|
+
with _identity_lock:
|
|
598
|
+
if not _identity_dirty:
|
|
599
|
+
return
|
|
600
|
+
snap, p = dict(_identity_mem), Path(_identity_path())
|
|
601
|
+
_identity_dirty, _identity_last_flush = False, time.monotonic()
|
|
623
602
|
try:
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
603
|
+
now = time.time()
|
|
604
|
+
with _paths.file_lock(p):
|
|
605
|
+
raw = json.loads(p.read_text(encoding="utf-8")) if p.exists() else {}
|
|
606
|
+
merged = {str(h): float(t) for h, t in raw.items() if isinstance(t, (int, float)) and float(t) > now} if isinstance(raw, dict) else {}
|
|
607
|
+
merged.update({h: exp for h, exp in snap.items() if exp > max(now, merged.get(h, 0.0))})
|
|
608
|
+
_paths.atomic_write_json(p, merged, indent=None)
|
|
609
|
+
except (*IO_BENIGN, ValueError):
|
|
629
610
|
pass
|
|
630
611
|
|
|
631
612
|
|
|
613
|
+
def _identity_remember_mobile(host: str) -> None:
|
|
614
|
+
"""记录「该 host 移动端身份成功过」,最多每 30s 写盘 + atexit 兜底。"""
|
|
615
|
+
global _identity_dirty, _identity_atexit_registered
|
|
616
|
+
if not host:
|
|
617
|
+
return
|
|
618
|
+
with _identity_lock:
|
|
619
|
+
_identity_load_locked()
|
|
620
|
+
if len(_identity_mem) >= 512:
|
|
621
|
+
_identity_mem.pop(next(iter(_identity_mem)), None)
|
|
622
|
+
_identity_mem[host] = time.time() + _IDENTITY_TTL
|
|
623
|
+
_identity_dirty = True
|
|
624
|
+
if not _identity_atexit_registered:
|
|
625
|
+
atexit.register(_identity_flush)
|
|
626
|
+
_identity_atexit_registered = True
|
|
627
|
+
need_flush = _identity_last_flush == 0.0 or (time.monotonic() - _identity_last_flush) >= _IDENTITY_FLUSH_INTERVAL
|
|
628
|
+
if need_flush:
|
|
629
|
+
_identity_flush()
|
|
630
|
+
|
|
631
|
+
|
|
632
632
|
def _identity_is_mobile(host: str) -> bool:
|
|
633
633
|
"""该 host 近 24h 内移动身份是否成功过。"""
|
|
634
634
|
if not host:
|
|
635
635
|
return False
|
|
636
|
-
|
|
637
|
-
|
|
636
|
+
with _identity_lock:
|
|
637
|
+
_identity_load_locked()
|
|
638
|
+
return _identity_mem.get(host, 0) > time.time()
|
|
638
639
|
|
|
639
640
|
|
|
640
641
|
def _mobile_http_fetch(url: str, max_chars: int = 8000,
|
|
@@ -858,7 +859,7 @@ def _archive_truncated(url: str, text: str, delivered: str, kind: str,
|
|
|
858
859
|
extra[f"full_{kind}_path"] = path
|
|
859
860
|
if primary:
|
|
860
861
|
extra["full_text_path"] = path
|
|
861
|
-
except
|
|
862
|
+
except OPT_IMPORT + IO_BENIGN:
|
|
862
863
|
pass
|
|
863
864
|
|
|
864
865
|
|
|
@@ -899,25 +900,20 @@ def _make_result(url: str, html: str, max_chars: int,
|
|
|
899
900
|
try:
|
|
900
901
|
from article_meta import extract_article_meta
|
|
901
902
|
result.update(extract_article_meta(html, url))
|
|
902
|
-
except
|
|
903
|
+
except OPT_IMPORT + SHAPE_BENIGN:
|
|
903
904
|
pass
|
|
904
905
|
result.update(extra)
|
|
905
906
|
return result
|
|
906
907
|
|
|
907
908
|
|
|
908
|
-
# ───
|
|
909
|
+
# ─── 第三方代理公网边界(jina 与 Parallel 共用;请求层见 fetch_jina.py)─────
|
|
909
910
|
|
|
910
911
|
_JINA_PRIVATE_HOST = re.compile(
|
|
911
912
|
r"^(localhost|127\.|10\.|192\.168\.|172\.(1[6-9]|2\d|3[01])\.|169\.254\.|0\.)")
|
|
912
913
|
|
|
913
914
|
|
|
914
|
-
def _jina_enabled() -> bool:
|
|
915
|
-
"""r.jina.ai 阅读器级开关:ARGO_FETCH_JINA=0 关闭,默认开启。"""
|
|
916
|
-
return env_flag("ARGO_FETCH_JINA")
|
|
917
|
-
|
|
918
|
-
|
|
919
915
|
def _is_public_host(host: str) -> bool:
|
|
920
|
-
"""r.jina.ai
|
|
916
|
+
"""第三方代理(r.jina.ai / Parallel)只接公网 URL。
|
|
921
917
|
|
|
922
918
|
内网/本机/裸 IP 一律跳过——把内部地址送出第三方 = 拓扑泄露;
|
|
923
919
|
域名形 IP(全数字)与含冒号的 IPv6 字面量同判为裸地址。
|
|
@@ -933,42 +929,6 @@ def _is_public_host(host: str) -> bool:
|
|
|
933
929
|
return "." in host
|
|
934
930
|
|
|
935
931
|
|
|
936
|
-
def _jina_reader_fetch(url: str, max_chars: int = 8000,
|
|
937
|
-
timeout: float = 8.0) -> dict | None:
|
|
938
|
-
"""r.jina.ai 阅读器(keyless 免费层)。
|
|
939
|
-
|
|
940
|
-
定位:HTTP/TLS 直连全败后的免浏览器快速路径——jina 在远端渲染并返回
|
|
941
|
-
markdown,命中则免去 CDP 冷启动。免费层有速率限制,失败/429 返回 None
|
|
942
|
-
静默放行走 Wayback/浏览器。调用方须先过 _is_public_host(第三方代理边界)。
|
|
943
|
-
"""
|
|
944
|
-
try:
|
|
945
|
-
from http_client import HttpClient
|
|
946
|
-
client = HttpClient(timeout=min(timeout, 10.0), max_retries=0,
|
|
947
|
-
jitter=False)
|
|
948
|
-
resp = client.get(f"https://r.jina.ai/{url}", extra_headers={
|
|
949
|
-
"User-Agent": "argo-fetch-v3/1.0 (+local-research; jina-reader)",
|
|
950
|
-
"Accept": "text/plain",
|
|
951
|
-
})
|
|
952
|
-
except Exception:
|
|
953
|
-
return None
|
|
954
|
-
if resp.get("status", 0) != 200 or not resp.get("text"):
|
|
955
|
-
return None
|
|
956
|
-
raw = resp["text"]
|
|
957
|
-
title = ""
|
|
958
|
-
m = re.search(r"^Title:\s*(.+)$", raw[:2000], re.MULTILINE)
|
|
959
|
-
if m:
|
|
960
|
-
title = m.group(1).strip()[:200]
|
|
961
|
-
if "Markdown Content:" in raw:
|
|
962
|
-
raw = raw.split("Markdown Content:", 1)[1].lstrip()
|
|
963
|
-
if not _looks_like_markdown(raw):
|
|
964
|
-
return None
|
|
965
|
-
result = _make_result(url, "", max_chars, engine_states.FETCH_JINA_READER)
|
|
966
|
-
result["content"] = raw[:max_chars]
|
|
967
|
-
result["length"] = len(result["content"])
|
|
968
|
-
result["title"] = title
|
|
969
|
-
return result
|
|
970
|
-
|
|
971
|
-
|
|
972
932
|
# ─── 第一级D:Parallel 免费 MCP web_fetch(keyless 云端渲染+提取)────────────
|
|
973
933
|
|
|
974
934
|
_PARALLEL_MCP_URL = "https://search.parallel.ai/mcp"
|
|
@@ -1306,7 +1266,7 @@ def fetch_v3(url: str, max_chars: int = 8000, timeout: float = 8.0,
|
|
|
1306
1266
|
_declared_ok = _video.get("content_ok")
|
|
1307
1267
|
try:
|
|
1308
1268
|
_video = _assess_quality(_video)
|
|
1309
|
-
except
|
|
1269
|
+
except SHAPE_BENIGN:
|
|
1310
1270
|
pass
|
|
1311
1271
|
_video["content_ok"] = bool(_declared_ok)
|
|
1312
1272
|
_video["page_type"] = "video"
|
|
@@ -1314,22 +1274,9 @@ def fetch_v3(url: str, max_chars: int = 8000, timeout: float = 8.0,
|
|
|
1314
1274
|
_video["cached"] = False
|
|
1315
1275
|
return _strip_html_unless_needed(_video, need_html)
|
|
1316
1276
|
|
|
1317
|
-
#
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
if robots_blocked(url, timeout=min(timeout, 5.0)):
|
|
1321
|
-
result = _make_result(url, "", 0, engine_states.FETCH_ROBOTS_BLOCKED, ok=False,
|
|
1322
|
-
error="robots.txt 禁止抓取")
|
|
1323
|
-
result = _assess_quality(result)
|
|
1324
|
-
result["cached"] = False
|
|
1325
|
-
return _strip_html_unless_needed(result, need_html)
|
|
1326
|
-
except ImportError:
|
|
1327
|
-
pass
|
|
1328
|
-
|
|
1329
|
-
# 微信公众号文章走专用降级链(HTTP→CDP→搜狗,唯一来源 wechat_article.py,
|
|
1330
|
-
# 即 `argo wx` 同一实现):通用 HTML 链对 mp.weixin 只能拿到 JS 骨架,
|
|
1331
|
-
# 正文全空(2026-11-01 实测缺口:fetch 对 mp.weixin 零处理)。robots 已在
|
|
1332
|
-
# 上方拦截,这里只做域名分流;need_html/actions/force_browser 同视频分支让路。
|
|
1277
|
+
# 微信专用降级链(HTTP→CDP→搜狗,wechat_article.py,`argo wx` 同实现——用户
|
|
1278
|
+
# 显式取文不走匿名爬虫 robots 口径)【必须在 robots 闸前】mp.weixin/robots.txt
|
|
1279
|
+
# 是 Disallow: /(11-15 实测),闸先跑分支永不可达(6ebb625 实跑复现)。让路同前。
|
|
1333
1280
|
if (_is_wechat_article_url(url) and not need_html and not actions
|
|
1334
1281
|
and not force_browser):
|
|
1335
1282
|
try:
|
|
@@ -1352,7 +1299,7 @@ def fetch_v3(url: str, max_chars: int = 8000, timeout: float = 8.0,
|
|
|
1352
1299
|
}
|
|
1353
1300
|
try:
|
|
1354
1301
|
_wx_result = _assess_quality(_wx_result)
|
|
1355
|
-
except
|
|
1302
|
+
except SHAPE_BENIGN:
|
|
1356
1303
|
pass
|
|
1357
1304
|
_wx_result["cached"] = False
|
|
1358
1305
|
return _strip_html_unless_needed(_wx_result, need_html)
|
|
@@ -1368,6 +1315,18 @@ def fetch_v3(url: str, max_chars: int = 8000, timeout: float = 8.0,
|
|
|
1368
1315
|
"cached": False,
|
|
1369
1316
|
}, need_html)
|
|
1370
1317
|
|
|
1318
|
+
# robots.txt 尊重(合规检查):被禁路径直接拒绝,抓取失败放行
|
|
1319
|
+
try:
|
|
1320
|
+
from robots_guard import robots_blocked
|
|
1321
|
+
if robots_blocked(url, timeout=min(timeout, 5.0)):
|
|
1322
|
+
result = _make_result(url, "", 0, engine_states.FETCH_ROBOTS_BLOCKED, ok=False,
|
|
1323
|
+
error="robots.txt 禁止抓取")
|
|
1324
|
+
result = _assess_quality(result)
|
|
1325
|
+
result["cached"] = False
|
|
1326
|
+
return _strip_html_unless_needed(result, need_html)
|
|
1327
|
+
except ImportError:
|
|
1328
|
+
pass
|
|
1329
|
+
|
|
1371
1330
|
# 登录态车道(A2):站点有 argo auth 持久 profile → 跳过匿名链直进浏览器。
|
|
1372
1331
|
# 匿名 HTTP 对已登录站只会拿到「登出态」内容——那是成功的假象,比失败更糟。
|
|
1373
1332
|
# 判断本体在 browser_auth(含开关与 use_browser_fallback=False 让路);
|
|
@@ -1419,7 +1378,7 @@ def fetch_v3(url: str, max_chars: int = 8000, timeout: float = 8.0,
|
|
|
1419
1378
|
if (out.get("quality_breakdown") or {}).get("version") != _v:
|
|
1420
1379
|
out = _quality.assess(out)
|
|
1421
1380
|
out["quality_basis"] = "rescored"
|
|
1422
|
-
except
|
|
1381
|
+
except SHAPE_BENIGN:
|
|
1423
1382
|
pass
|
|
1424
1383
|
out["cached"] = True
|
|
1425
1384
|
out["cache_level"] = hit.get("_cache_level", engine_states.CACHE_LEVEL_UNKNOWN)
|
|
@@ -1560,15 +1519,15 @@ def fetch_v3(url: str, max_chars: int = 8000, timeout: float = 8.0,
|
|
|
1560
1519
|
result = spoof
|
|
1561
1520
|
|
|
1562
1521
|
if not result.get("stop_signal") and _budget_left() > 0:
|
|
1563
|
-
# 第一级C:r.jina.ai
|
|
1522
|
+
# 第一级C:r.jina.ai 阅读器(请求层见 fetch_jina.py)。
|
|
1564
1523
|
# HTTP/TLS 直连全败时的免浏览器快速路径;markdown-only 同
|
|
1565
1524
|
# tinyfish,need_html 场景跳过;第三方代理只接公网 URL。
|
|
1566
|
-
if (not gated and not need_html and
|
|
1525
|
+
if (not gated and not need_html and _fetch_jina.enabled()
|
|
1567
1526
|
and _is_public_host(host)
|
|
1568
1527
|
and (not result.get("success")
|
|
1569
1528
|
or _needs_browser(result))):
|
|
1570
1529
|
# 超时受剩余预算约束:deadline 场景本级不得击穿总预算
|
|
1571
|
-
jina =
|
|
1530
|
+
jina = _fetch_jina.fetch(
|
|
1572
1531
|
url, max_chars, timeout=_level_timeout(timeout))
|
|
1573
1532
|
if jina is not None and jina.get("success"):
|
|
1574
1533
|
jina["http_fallback"] = True
|
|
@@ -1624,7 +1583,7 @@ def fetch_v3(url: str, max_chars: int = 8000, timeout: float = 8.0,
|
|
|
1624
1583
|
result = tf
|
|
1625
1584
|
# tinyfish 未命中(关闭/缺 key/失败/短内容)才起本地 Chrome——
|
|
1626
1585
|
# 内容过短的成功响应与失败同样需要继续降级
|
|
1627
|
-
if result.get("fetch_method")
|
|
1586
|
+
if result.get("fetch_method") not in (_render_tinyfish.TINYFISH_METHOD, engine_states.FETCH_JSRUN_CHALLENGE):
|
|
1628
1587
|
browser_result = _browser_fetch(
|
|
1629
1588
|
url, max_chars, timeout=_level_timeout(15.0))
|
|
1630
1589
|
if browser_result.get("success") or not result.get("success"):
|
|
@@ -1645,7 +1604,7 @@ def fetch_v3(url: str, max_chars: int = 8000, timeout: float = 8.0,
|
|
|
1645
1604
|
from article_meta import extract_article_meta
|
|
1646
1605
|
for _mk, _mv in extract_article_meta(result["html"], url).items():
|
|
1647
1606
|
result.setdefault(_mk, _mv)
|
|
1648
|
-
except
|
|
1607
|
+
except OPT_IMPORT + SHAPE_BENIGN:
|
|
1649
1608
|
pass
|
|
1650
1609
|
|
|
1651
1610
|
# 写 URL 缓存(不存大块 html,省空间)
|
|
@@ -1677,7 +1636,7 @@ def fetch_v3(url: str, max_chars: int = 8000, timeout: float = 8.0,
|
|
|
1677
1636
|
if ev:
|
|
1678
1637
|
to_store[FETCH_EVIDENCE_KEY] = {
|
|
1679
1638
|
k: v for k, v in ev.items() if k != "url"}
|
|
1680
|
-
except
|
|
1639
|
+
except OPT_IMPORT + SHAPE_BENIGN:
|
|
1681
1640
|
pass
|
|
1682
1641
|
SearchCache().set_fetch(url, to_store, ttl=ttl)
|
|
1683
1642
|
except Exception:
|