@jayyuen66/dsh-scrapling 0.1.17 → 0.2.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/CHANGELOG.md +56 -0
- package/README.md +150 -265
- package/README.zh-CN.md +218 -333
- package/THIRD_PARTY_NOTICES.md +52 -15
- package/bin/dsh-scrapling.mjs +12 -73
- package/client.js +6 -6
- package/docs/DETAIL.md +19 -28
- package/docs/DETAIL.zh.md +24 -33
- package/docs/images/architecture.svg +100 -0
- package/docs/images/architecture.zh.svg +99 -0
- package/docs/images/tool-selection.svg +88 -0
- package/docs/images/tool-selection.zh.svg +88 -0
- package/host.js +23 -46
- package/package.json +64 -62
- package/py/adapters.py +14 -13
- package/py/bridge.py +3 -3
- package/py/crawl.py +1 -1
- package/py/document.py +1 -1
- package/py/documents-requirements.txt +1 -1
- package/py/extraction.py +2 -2
- package/py/media.py +1 -1
- package/py/runtime-requirements.txt +3 -3
- package/py/search.py +3 -2
- package/py/session_page.py +2 -2
- package/runtime-manifest.json +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jayyuen66/dsh-scrapling",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Scrapling 网页抓取插件(dsh):静态/浏览器抓取 + CSS/XPath 结构化抽取 + 选择器自愈 + capture_xhr 与会话网络历史 + 登录态存取 + Spider 爬虫,由常驻 Python 进程驱动。",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dsh",
|
|
@@ -72,74 +72,76 @@
|
|
|
72
72
|
"registry": "https://registry.npmjs.org"
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
|
-
"@jayyuen66/dsh-plugin-shared": "^0.
|
|
75
|
+
"@jayyuen66/dsh-plugin-shared": "^0.3.1",
|
|
76
76
|
"@modelcontextprotocol/sdk": "1.32.2",
|
|
77
|
-
"fs-native-extensions": "1.5.
|
|
77
|
+
"fs-native-extensions": "1.5.5",
|
|
78
78
|
"ipaddr.js": "2.5.0",
|
|
79
79
|
"zod": "4.6.7"
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
82
|
-
"@deepseek-ai/cordis": "4.2.0-alpha.
|
|
83
|
-
"@deepseek-ai/cordis-plugin-include": "1.2.0-alpha.
|
|
84
|
-
"@deepseek-ai/cordis-plugin-loader": "1.2.0-alpha.
|
|
85
|
-
"@deepseek-ai/dsh-api-remotes": "0.2.3-alpha.
|
|
86
|
-
"@deepseek-ai/dsh-client-locale": "0.2.3-alpha.
|
|
87
|
-
"@deepseek-ai/dsh-client-store": "0.2.3-alpha.
|
|
88
|
-
"@deepseek-ai/dsh-client-ui-chat": "0.2.3-alpha.
|
|
89
|
-
"@deepseek-ai/dsh-client-ui-conversation": "0.2.3-alpha.
|
|
90
|
-
"@deepseek-ai/dsh-client-ui-layout": "0.2.3-alpha.
|
|
91
|
-
"@deepseek-ai/dsh-client-ui-plugin-manager": "0.2.3-alpha.
|
|
92
|
-
"@deepseek-ai/dsh-client-ui-renderer": "0.2.3-alpha.
|
|
93
|
-
"@deepseek-ai/dsh-client-ui-settings": "0.2.3-alpha.
|
|
94
|
-
"@deepseek-ai/dsh-client-ui-slots": "0.2.3-alpha.
|
|
95
|
-
"@deepseek-ai/dsh-client-ui-tool": "0.2.3-alpha.
|
|
96
|
-
"@deepseek-ai/dsh-error": "0.2.3-alpha.
|
|
97
|
-
"@deepseek-ai/dsh-
|
|
98
|
-
"@deepseek-ai/dsh-
|
|
99
|
-
"@deepseek-ai/dsh-
|
|
100
|
-
"@deepseek-ai/dsh-jobs
|
|
101
|
-
"@deepseek-ai/dsh-
|
|
102
|
-
"@deepseek-ai/dsh-
|
|
103
|
-
"@deepseek-ai/dsh-
|
|
104
|
-
"@deepseek-ai/dsh-
|
|
105
|
-
"@deepseek-ai/dsh-
|
|
106
|
-
"@deepseek-ai/dsh-
|
|
107
|
-
"@deepseek-ai/dsh-
|
|
108
|
-
"@deepseek-ai/dsh-
|
|
109
|
-
"@deepseek-ai/dsh-
|
|
110
|
-
"@deepseek-ai/dsh-
|
|
111
|
-
"@deepseek-ai/dsh-
|
|
112
|
-
"@deepseek-ai/dsh-
|
|
113
|
-
"@deepseek-ai/dsh-
|
|
114
|
-
"@deepseek-ai/dsh-
|
|
115
|
-
"@deepseek-ai/dsh-
|
|
116
|
-
"@deepseek-ai/
|
|
82
|
+
"@deepseek-ai/cordis": "4.2.0-alpha.2",
|
|
83
|
+
"@deepseek-ai/cordis-plugin-include": "1.2.0-alpha.2",
|
|
84
|
+
"@deepseek-ai/cordis-plugin-loader": "1.2.0-alpha.2",
|
|
85
|
+
"@deepseek-ai/dsh-api-remotes": "0.2.3-alpha.3",
|
|
86
|
+
"@deepseek-ai/dsh-client-locale": "0.2.3-alpha.3",
|
|
87
|
+
"@deepseek-ai/dsh-client-store": "0.2.3-alpha.3",
|
|
88
|
+
"@deepseek-ai/dsh-client-ui-chat": "0.2.3-alpha.3",
|
|
89
|
+
"@deepseek-ai/dsh-client-ui-conversation": "0.2.3-alpha.3",
|
|
90
|
+
"@deepseek-ai/dsh-client-ui-layout": "0.2.3-alpha.3",
|
|
91
|
+
"@deepseek-ai/dsh-client-ui-plugin-manager": "0.2.3-alpha.3",
|
|
92
|
+
"@deepseek-ai/dsh-client-ui-renderer": "0.2.3-alpha.3",
|
|
93
|
+
"@deepseek-ai/dsh-client-ui-settings": "0.2.3-alpha.3",
|
|
94
|
+
"@deepseek-ai/dsh-client-ui-slots": "0.2.3-alpha.3",
|
|
95
|
+
"@deepseek-ai/dsh-client-ui-tool": "0.2.3-alpha.3",
|
|
96
|
+
"@deepseek-ai/dsh-error": "0.2.3-alpha.3",
|
|
97
|
+
"@deepseek-ai/dsh-fs-patch": "0.2.3-alpha.3",
|
|
98
|
+
"@deepseek-ai/dsh-host-webserver": "0.2.3-alpha.3",
|
|
99
|
+
"@deepseek-ai/dsh-http-proxy": "0.2.3-alpha.3",
|
|
100
|
+
"@deepseek-ai/dsh-jobs": "0.2.3-alpha.3",
|
|
101
|
+
"@deepseek-ai/dsh-jobs-local": "0.2.3-alpha.3",
|
|
102
|
+
"@deepseek-ai/dsh-output-retention": "0.2.3-alpha.3",
|
|
103
|
+
"@deepseek-ai/dsh-package-manifest": "0.2.3-alpha.3",
|
|
104
|
+
"@deepseek-ai/dsh-sandbox": "0.2.3-alpha.3",
|
|
105
|
+
"@deepseek-ai/dsh-scope": "0.2.3-alpha.3",
|
|
106
|
+
"@deepseek-ai/dsh-session": "0.2.3-alpha.3",
|
|
107
|
+
"@deepseek-ai/dsh-settings": "0.2.3-alpha.3",
|
|
108
|
+
"@deepseek-ai/dsh-shell": "0.2.3-alpha.3",
|
|
109
|
+
"@deepseek-ai/dsh-skill": "0.2.3-alpha.3",
|
|
110
|
+
"@deepseek-ai/dsh-subprocess": "0.2.3-alpha.3",
|
|
111
|
+
"@deepseek-ai/dsh-system-prompt": "0.2.3-alpha.3",
|
|
112
|
+
"@deepseek-ai/dsh-tool-registry-native": "0.2.3-alpha.3",
|
|
113
|
+
"@deepseek-ai/dsh-tools": "0.2.3-alpha.3",
|
|
114
|
+
"@deepseek-ai/dsh-typert-protocol": "0.2.3-alpha.3",
|
|
115
|
+
"@deepseek-ai/dsh-user-approval": "0.2.3-alpha.3",
|
|
116
|
+
"@deepseek-ai/dsh-web": "0.2.3-alpha.3",
|
|
117
|
+
"@deepseek-ai/schemastery": "3.20.0-alpha.2",
|
|
117
118
|
"@e18e/eslint-plugin": "0.8.1",
|
|
118
|
-
"@
|
|
119
|
-
"@types/
|
|
120
|
-
"@
|
|
119
|
+
"@rolldown/plugin-transform-imports": "0.1.3",
|
|
120
|
+
"@types/node": "26.6.11",
|
|
121
|
+
"@types/react": "19.3.3",
|
|
122
|
+
"@vitest/coverage-v8": "5.1.2",
|
|
121
123
|
"eslint-plugin-regexp": "3.3.3",
|
|
122
|
-
"eslint-plugin-sonarjs": "4.2.
|
|
123
|
-
"eslint-plugin-zod": "5.
|
|
124
|
-
"fast-check": "4.
|
|
125
|
-
"oxfmt": "0.
|
|
126
|
-
"oxlint": "1.
|
|
127
|
-
"oxlint-tsgolint": "7.0.
|
|
124
|
+
"eslint-plugin-sonarjs": "4.2.3",
|
|
125
|
+
"eslint-plugin-zod": "5.4.0",
|
|
126
|
+
"fast-check": "4.11.0",
|
|
127
|
+
"oxfmt": "0.80.0",
|
|
128
|
+
"oxlint": "1.95.0",
|
|
129
|
+
"oxlint-tsgolint": "7.0.2009",
|
|
128
130
|
"react": "^19.3.0",
|
|
129
131
|
"react-dom": "^19.3.0",
|
|
130
|
-
"rolldown": "1.3.
|
|
132
|
+
"rolldown": "1.3.4",
|
|
131
133
|
"typescript": "7.0.2",
|
|
132
|
-
"vite": "8.
|
|
133
|
-
"vitest": "5.1.
|
|
134
|
+
"vite": "8.4.0",
|
|
135
|
+
"vitest": "5.1.2"
|
|
134
136
|
},
|
|
135
137
|
"peerDependencies": {
|
|
136
|
-
"@deepseek-ai/dsh": "^0.2.3-alpha.
|
|
137
|
-
"@deepseek-ai/dsh-error": "^0.2.3-alpha.
|
|
138
|
-
"@deepseek-ai/dsh-output-retention": "^0.2.3-alpha.
|
|
139
|
-
"@deepseek-ai/dsh-tools": "^0.2.3-alpha.
|
|
140
|
-
"@deepseek-ai/dsh-typert-protocol": "^0.2.3-alpha.
|
|
141
|
-
"@deepseek-ai/dsh-web": "^0.2.3-alpha.
|
|
142
|
-
"@deepseek-ai/schemastery": "^3.20.0-alpha.
|
|
138
|
+
"@deepseek-ai/dsh": "^0.2.3-alpha.3",
|
|
139
|
+
"@deepseek-ai/dsh-error": "^0.2.3-alpha.3",
|
|
140
|
+
"@deepseek-ai/dsh-output-retention": "^0.2.3-alpha.3",
|
|
141
|
+
"@deepseek-ai/dsh-tools": "^0.2.3-alpha.3",
|
|
142
|
+
"@deepseek-ai/dsh-typert-protocol": "^0.2.3-alpha.3",
|
|
143
|
+
"@deepseek-ai/dsh-web": "^0.2.3-alpha.3",
|
|
144
|
+
"@deepseek-ai/schemastery": "^3.20.0-alpha.2"
|
|
143
145
|
},
|
|
144
146
|
"peerDependenciesMeta": {
|
|
145
147
|
"@deepseek-ai/dsh": {
|
|
@@ -148,7 +150,7 @@
|
|
|
148
150
|
},
|
|
149
151
|
"icon": "icon.svg",
|
|
150
152
|
"engines": {
|
|
151
|
-
"dsh": "^0.2.3-alpha.
|
|
153
|
+
"dsh": "^0.2.3-alpha.3",
|
|
152
154
|
"node": "^24.22.3 || >=26.13.1"
|
|
153
155
|
},
|
|
154
156
|
"dsh": {
|
|
@@ -165,9 +167,9 @@
|
|
|
165
167
|
}
|
|
166
168
|
},
|
|
167
169
|
"scripts": {
|
|
168
|
-
"build:client": "node build-client.
|
|
169
|
-
"build": "node build-host.
|
|
170
|
-
"typecheck": "tsc --noEmit -p tsconfig.json && tsc --noEmit -p tsconfig.client.json",
|
|
170
|
+
"build:client": "node build-client.mjs",
|
|
171
|
+
"build": "node build-host.mjs && node build-cli.mjs",
|
|
172
|
+
"typecheck": "tsc --noEmit -p tsconfig.json && tsc --noEmit -p tsconfig.client.json && tsc --noEmit -p tsconfig.build-scripts.json",
|
|
171
173
|
"lint": "oxlint .",
|
|
172
174
|
"test": "vitest run --coverage",
|
|
173
175
|
"test:watch": "vitest",
|
|
@@ -186,6 +188,6 @@
|
|
|
186
188
|
"coverage:floor": "node py-launcher.mjs -m coverage erase && node py-launcher.mjs --env=DSH_PY_COVERAGE=1 -m coverage run --parallel-mode py/tests/test_bridge.py && node py-launcher.mjs -m coverage combine && node py-launcher.mjs -m coverage report --omit=\"py/tests/*\" --fail-under=74 && node -e \"require('node:fs').mkdirSync('coverage',{recursive:true})\" && node py-launcher.mjs -m coverage json --omit=\"py/tests/*\" -o coverage/python-coverage.json && node coverage-floor.mjs && node py-launcher.mjs -m coverage erase",
|
|
187
189
|
"deps:py": "node deps-check.mjs",
|
|
188
190
|
"check:py": "npm run --loglevel=warn py:which && npm run --loglevel=warn face:py && npm run --loglevel=warn deps:py && npm run --loglevel=warn lint:py && npm run --loglevel=warn fmt:py && npm run --loglevel=warn typecheck:py && npm run --loglevel=warn bandit:py && npm run --loglevel=warn coverage:floor",
|
|
189
|
-
"build:cli": "node build-cli.
|
|
191
|
+
"build:cli": "node build-cli.mjs"
|
|
190
192
|
}
|
|
191
193
|
}
|
package/py/adapters.py
CHANGED
|
@@ -218,7 +218,7 @@ def _network_summary_with_count(
|
|
|
218
218
|
"status": item.status,
|
|
219
219
|
"bytes": len(body) if body else 0,
|
|
220
220
|
# 上游把方法记在 Response.method 上;从 meta / request_headers 读会退化成 GET,
|
|
221
|
-
# POST 的 XHR 在摘要里一律显示成 GET
|
|
221
|
+
# POST 的 XHR 在摘要里一律显示成 GET。
|
|
222
222
|
"method": str(getattr(item, "method", "GET")),
|
|
223
223
|
"resourceType": str(meta.get("resource_type") or ""),
|
|
224
224
|
}
|
|
@@ -444,7 +444,7 @@ def to_payload(
|
|
|
444
444
|
|
|
445
445
|
``json`` 是数据而不是正文:直接解析并序列化,不过 markdown 反注入清洗;但序列化后的
|
|
446
446
|
文本照旧剥 data URI(内联图片对模型不可读,还会白吃 ``maxContentChars`` 的额度)并受
|
|
447
|
-
同一个 ``maxContentChars`` 封顶——与 html/text/markdown
|
|
447
|
+
同一个 ``maxContentChars`` 封顶——与 html/text/markdown 三条路径同一套封顶流程。
|
|
448
448
|
"""
|
|
449
449
|
raise_if_cancelled()
|
|
450
450
|
if extraction_type == "json":
|
|
@@ -454,7 +454,7 @@ def to_payload(
|
|
|
454
454
|
raw = getattr(response, "html_content", "") or getattr(response, "text", "")
|
|
455
455
|
raise AdapterError("NOT_JSON", f"response is not JSON: {str(raw)[:200]}") from error
|
|
456
456
|
text = json.dumps(parsed, ensure_ascii=False)
|
|
457
|
-
#
|
|
457
|
+
# JSON 文本与正文走同一条剥图/清洗再封顶的路径:序列化之后的 data URI
|
|
458
458
|
# 同样会白吃 maxContentChars 的额度,而且内联图片是模型读不懂的字节。
|
|
459
459
|
if strip_inline_images:
|
|
460
460
|
text = drop_data_uris(text)
|
|
@@ -695,7 +695,7 @@ def fetch(args: dict[str, Any]) -> dict[str, Any]:
|
|
|
695
695
|
params["impersonate"] = impersonate
|
|
696
696
|
|
|
697
697
|
# Host 侧闸门判过之后到 curl_cffi 真解析、真建连之间隔着一个进程边界(TOCTOU),
|
|
698
|
-
# 所以这里在发车之前用同一份 guard 复判一次 —— 浏览器路径由 page.route
|
|
698
|
+
# 所以这里在发车之前用同一份 guard 复判一次 —— 浏览器路径由 page.route 逐请求拦截,
|
|
699
699
|
# 静态路径没有那一层,不在这里补就是「两道防线」只说了一半。判在写方法之后:那一条是
|
|
700
700
|
# 部署表态(非 GET 一律拒),与目标地址无关,不该被一条 URL_BLOCKED 盖掉。
|
|
701
701
|
allowed, reason = guard.url_allowed(url)
|
|
@@ -1165,8 +1165,9 @@ def _adaptive_kwargs(args: dict[str, Any], url: str) -> dict[str, Any]:
|
|
|
1165
1165
|
"""按部署表态给出 adaptive 指纹库的 storage 与 storage_args。
|
|
1166
1166
|
|
|
1167
1167
|
``deployment.adaptiveStorage`` 只认 ``sqlite``(默认)与 ``redis``;Redis 那一支把连接
|
|
1168
|
-
串与按注册域分桶的 ``url`` 一起交给 ``RedisStorageSystem
|
|
1169
|
-
``
|
|
1168
|
+
串与按注册域分桶的 ``url`` 一起交给 ``RedisStorageSystem``。存储层连不上时不让抽取
|
|
1169
|
+
失败:调用方降级为不带 adaptive 的普通抽取,notice 带 ``ADAPTIVE_STORAGE_FAILED``
|
|
1170
|
+
与原因。
|
|
1170
1171
|
"""
|
|
1171
1172
|
deployment = args.get("deployment")
|
|
1172
1173
|
settings = deployment if isinstance(deployment, dict) else {}
|
|
@@ -1279,7 +1280,7 @@ def select(args: dict[str, Any]) -> dict[str, Any]:
|
|
|
1279
1280
|
# 替换而不是补齐,漏了 url 全部指纹都会落进 default 桶。url 为空时也显式传空串,
|
|
1280
1281
|
# 存储层把它归入 default 桶(StorageSystemMixin 对空值有兜底)。
|
|
1281
1282
|
#
|
|
1282
|
-
#
|
|
1283
|
+
# 存储故障**不使抽取失败** —— 降级为不带 adaptive 的普通
|
|
1283
1284
|
# Selector 再抽一次,正文照常返回,notice 带 ADAPTIVE_STORAGE_FAILED 与原因。
|
|
1284
1285
|
# sqlite 与 redis 两侧同解:指纹库坏了不该让模型连正文都拿不到。
|
|
1285
1286
|
try:
|
|
@@ -1628,7 +1629,7 @@ class _SessionWorker:
|
|
|
1628
1629
|
self._thread.join(timeout=5.0)
|
|
1629
1630
|
|
|
1630
1631
|
def alive(self) -> bool:
|
|
1631
|
-
"""
|
|
1632
|
+
"""属主线程是否还在跑(只读判据,不改动任何状态)。"""
|
|
1632
1633
|
return not self._closed.is_set() and self._thread.is_alive()
|
|
1633
1634
|
|
|
1634
1635
|
|
|
@@ -1829,7 +1830,7 @@ def session_open(args: dict[str, Any]) -> dict[str, Any]:
|
|
|
1829
1830
|
"closer": closer, # 关它用的对象(static 是 wrapper,浏览器是自身)
|
|
1830
1831
|
"type": kind,
|
|
1831
1832
|
"created_at": datetime.now(timezone.utc).isoformat(),
|
|
1832
|
-
#
|
|
1833
|
+
# 非敏感设置摘要:在开场时把生效值记下来,session.list 不必回头去
|
|
1833
1834
|
# 猜(凭据一类的东西永远不进这份摘要)。
|
|
1834
1835
|
"settings": _session_settings(kind, args),
|
|
1835
1836
|
# 同一把锁:占位时建的那把,盖回来而不是新建 —— 新建会让构造期与使用期各锁各的。
|
|
@@ -2092,7 +2093,7 @@ def screenshot(args: dict[str, Any]) -> dict[str, Any]:
|
|
|
2092
2093
|
|
|
2093
2094
|
|
|
2094
2095
|
def _session_settings(kind: str, args: dict[str, Any]) -> dict[str, Any]:
|
|
2095
|
-
"""
|
|
2096
|
+
"""会话的非敏感设置摘要。
|
|
2096
2097
|
|
|
2097
2098
|
只收「这次会话是怎么配的」的开关,绝不包含 cookies、代理凭据或任何 key —— 这份
|
|
2098
2099
|
摘要会被模型读到。静态会话没有浏览器那一组开关,逐项给 null。
|
|
@@ -2135,7 +2136,7 @@ def _session_alive(entry: dict[str, Any]) -> bool:
|
|
|
2135
2136
|
def _pool_stats(entry: dict[str, Any]) -> dict[str, int] | None:
|
|
2136
2137
|
"""浏览器会话的页池统计;没有这条能力或取不到时给 None(绝不抛)。
|
|
2137
2138
|
|
|
2138
|
-
|
|
2139
|
+
``poolStats`` 是可选字段:一只已经跑完开始收尾的会话也可能在取统计的一瞬
|
|
2139
2140
|
出错,那不该把整个 session.list 变成一次失败。
|
|
2140
2141
|
|
|
2141
2142
|
:param entry: 登记条目
|
|
@@ -2149,7 +2150,7 @@ def _pool_stats(entry: dict[str, Any]) -> dict[str, int] | None:
|
|
|
2149
2150
|
return None
|
|
2150
2151
|
try:
|
|
2151
2152
|
stats = getter()
|
|
2152
|
-
except Exception: # noqa: BLE001 ——
|
|
2153
|
+
except Exception: # noqa: BLE001 —— 统计拿不到时省略,不许让 list 整体失败
|
|
2153
2154
|
return None
|
|
2154
2155
|
if not isinstance(stats, dict):
|
|
2155
2156
|
return None
|
|
@@ -2336,7 +2337,7 @@ def _session_state(args: dict[str, Any], *, saving: bool) -> dict[str, Any]:
|
|
|
2336
2337
|
try:
|
|
2337
2338
|
if saving:
|
|
2338
2339
|
worker.run(lambda: session.save_state(target))
|
|
2339
|
-
#
|
|
2340
|
+
# 登录态文件是凭据一类的东西(cookie / localStorage / IndexedDB),写到磁盘后
|
|
2340
2341
|
# 收到 0600。Windows 上 chmod 只动只读位,失败也不该让存取整体失败。
|
|
2341
2342
|
with contextlib.suppress(OSError):
|
|
2342
2343
|
Path(target).chmod(0o600)
|
package/py/bridge.py
CHANGED
|
@@ -55,7 +55,7 @@ if TYPE_CHECKING:
|
|
|
55
55
|
# 管道在 Windows 上默认走本地 ANSI 代码页;`LC_ALL=C` 配上 `PYTHONUTF8=0` 这类环境
|
|
56
56
|
# 也会让它们退成 ascii —— 那时 emit 里的非 ASCII 正文会抛 UnicodeEncodeError,而
|
|
57
57
|
# worker 把它当请求异常吞掉,调用方拿不到任何响应,只能等到超时。
|
|
58
|
-
# backslashreplace
|
|
58
|
+
# backslashreplace 处理另一个方向:json.loads 能把 "\ud800" 解成孤立代理项,严格编码
|
|
59
59
|
# 会让整帧写不出去,替换成转义文本至少留下可读的痕迹。
|
|
60
60
|
# 用 getattr 取 reconfigure:被重定向成 io.StringIO 的流没有这个方法(测试与嵌宿主都可能
|
|
61
61
|
# 这么做),缺了它不该让整个 sidecar 起不来。
|
|
@@ -467,7 +467,7 @@ def _drain_before_exit(timeout: float = 5.0) -> None:
|
|
|
467
467
|
|
|
468
468
|
点名只覆盖队列里的帧:已经出队、正在 handler 里跑的请求没有一处集中的登记面,要命名
|
|
469
469
|
它们就得在 worker 的热路径上加簿记,这比一条关机日志不值。那一路的后果由
|
|
470
|
-
`_shutdown_crawls` / `_shutdown_sessions`
|
|
470
|
+
`_shutdown_crawls` / `_shutdown_sessions` 的有界关闭负责清理(宿主侧等的是帧,不是关闭)。
|
|
471
471
|
|
|
472
472
|
:param timeout - 最长等待秒数
|
|
473
473
|
"""
|
|
@@ -513,7 +513,7 @@ def read_loop() -> int:
|
|
|
513
513
|
# 必须按块读(read1),既不能用 read(65536),也不能用 readline()。
|
|
514
514
|
# BufferedReader.read(n) 的语义是「读满 n 字节或遇到 EOF」:宿主只要保持管道开着
|
|
515
515
|
# (而常驻进程本来就该一直开着),它就会一直等下去,第一个请求永远进不来。
|
|
516
|
-
#
|
|
516
|
+
# 批量发完立刻 close stdin 的探针能靠这条语义侥幸通过,逐帧交互的客户端会挂死。
|
|
517
517
|
# readline() 则把整行读进内存**才**交回来:宿主侧 FrameSplitter 在
|
|
518
518
|
# MAX_FRAME_BYTES 处增量截断,这里若等整行,一个不带换行的超长写入仍会把无界字节
|
|
519
519
|
# 吃进内存(两侧同解的对称性缺口)。read1 有多少给多少,配合自建的 pending
|
package/py/crawl.py
CHANGED
|
@@ -350,7 +350,7 @@ def _make_spider(
|
|
|
350
350
|
"""把爬虫的会话换成「只跟安全重定向、走配置里那份代理」的那一份。
|
|
351
351
|
|
|
352
352
|
Spider 默认加的是不带参数的 ``FetcherSession()``,重定向按 curl_cffi 的默认走 —— 跳向私网
|
|
353
|
-
不会被拦。Host 闸门只判起点 URL
|
|
353
|
+
不会被拦。Host 闸门只判起点 URL,重定向目标是它看不到的,所以这里必须自己拦:
|
|
354
354
|
``follow_redirects="safe"`` 让 curl_cffi 拒绝跳向私网的跳转。
|
|
355
355
|
|
|
356
356
|
代理按起点 URL 定档(``allowed_domains`` 已经把爬虫锁在起点所在的域里,所以
|
package/py/document.py
CHANGED
|
@@ -36,7 +36,7 @@ def _positive(value: Any, field: str, default: int) -> int:
|
|
|
36
36
|
|
|
37
37
|
|
|
38
38
|
def _limits(args: dict[str, Any]) -> tuple[int, int, int]:
|
|
39
|
-
"""
|
|
39
|
+
"""模型上限只能向下收,部署缺省值就是各参数声明的三档默认值。"""
|
|
40
40
|
deployment = args.get("deployment")
|
|
41
41
|
if deployment is None:
|
|
42
42
|
deployment = {}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
pypdf==7.
|
|
1
|
+
pypdf==7.2.0 --hash=sha256:5edb9b033dd55cecead9303370e6854c1a3b979669bde1c46024cde0228405b1
|
package/py/extraction.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"""选择器查询与字段抽取的纯函数。
|
|
2
2
|
|
|
3
3
|
只做 HTML 到 Python 值的转换;不读环境、不发请求、不处理 protocol 帧。
|
|
4
|
-
`adapters.select` 负责参数错误码,`locate`/`links`
|
|
4
|
+
`adapters.select` 负责参数错误码,`locate`/`links` 复用这里的查询与序列化。
|
|
5
5
|
"""
|
|
6
6
|
|
|
7
7
|
from __future__ import annotations
|
|
@@ -464,7 +464,7 @@ def links(args: dict[str, Any]) -> dict[str, Any]:
|
|
|
464
464
|
extractor = LinkExtractor(**options)
|
|
465
465
|
except Exception as error:
|
|
466
466
|
raise ValueError(f"invalid link rule: {error}") from error
|
|
467
|
-
# 上游把注解写成 Response,实际只读 .url 与 .css
|
|
467
|
+
# 上游把注解写成 Response,实际只读 .url 与 .css;传 Selector 实测可用。
|
|
468
468
|
urls = list(extractor.extract(cast(Any, page)))
|
|
469
469
|
truncated = len(urls) > limit
|
|
470
470
|
kept = urls[:limit]
|
package/py/media.py
CHANGED
|
@@ -218,7 +218,7 @@ def _download_via_stream(
|
|
|
218
218
|
if not 200 <= status < 300:
|
|
219
219
|
raise _error("DOWNLOAD_FAILED", f"download answered HTTP {status}")
|
|
220
220
|
declared = _header_value(response.headers, "Content-Length")
|
|
221
|
-
#
|
|
221
|
+
# 头部预检在正文传输之前给出结论;谎报长度的服务端由流式循环里的复核拦下。
|
|
222
222
|
if declared.isdigit() and int(declared) > limit:
|
|
223
223
|
raise _error(
|
|
224
224
|
too_large_code,
|
|
@@ -5,7 +5,7 @@ apify_fingerprint_datapoints==0.15.0 --hash=sha256:fc9299b3136880f47b468897cd00a
|
|
|
5
5
|
attrs==26.1.0 --hash=sha256:c647aa4a12dfbad9333ca4e71fe62ddc36f4e63b2d260a37a8b83d2f043ac309
|
|
6
6
|
beautifulsoup4==4.15.0 --hash=sha256:d6f88de62e1d4e38ecb1077eb9724cd0eff29d2a08ca16a401e9b9e93f117cf9
|
|
7
7
|
browserforge==1.2.4 --hash=sha256:fb1c14e62ac09de221dcfc73074200269f697596c642cb200ceaab1127a17542
|
|
8
|
-
certifi==2026.
|
|
8
|
+
certifi==2026.11.20 --hash=sha256:7422df25243767b9877031a2248cb14d09ddac9beee846f4cef3d5c9191d488f
|
|
9
9
|
cffi==2.1.1 --hash=sha256:661c298b4821edebead0c91edd2b00374d67ad7c5a1f7a91d4442633b79d6a72
|
|
10
10
|
click==8.5.0 --hash=sha256:255bc9599cf7748b4b1a446ccc735421bd08a2ae529a8b88597d3de5664ee360
|
|
11
11
|
cryptography==50.0.2 --hash=sha256:fa8f5efb344d6908a1ce62f4a24e2e5780f825d6f53f5f50ec5ffacac72936cb
|
|
@@ -23,7 +23,7 @@ markdownify==1.2.3 --hash=sha256:a189a0bedfd14009030fde5f85bb6f77c56897cb839b5c2
|
|
|
23
23
|
mcp==2.3.0 --hash=sha256:dd0c44c089d16453e8ae31a3877a0054d7a2314caaa81f5e0541b9b1734b2377
|
|
24
24
|
mcp-types==2.3.0 --hash=sha256:968efdbdaedfab06adae40d378a34395f1090c5921d4be3c9cde283aaf76d91d
|
|
25
25
|
msgspec==0.22.0 --hash=sha256:dd9568695911055440d2bb7099ed9098fc181d335daa772d0eb3fe8f31ba4efb
|
|
26
|
-
opentelemetry-api==1.45.
|
|
26
|
+
opentelemetry-api==1.45.2 --hash=sha256:2cbd737377e710ee740d261c94e93fa0f08e6d037c18f17513cc0a2d94479a34
|
|
27
27
|
orjson==3.13.0 --hash=sha256:91d933e668ff0ffe164d7c2daec36beba6d1ce7fadb71538fbe142a71f8a1e6e
|
|
28
28
|
patchright==1.64.2 --hash=sha256:c36a071c259f6e99f5b69ec5a2c4993ea3c274b04d324eed914e5937b0d7c218
|
|
29
29
|
playwright==1.64.1 --hash=sha256:59f7b041284ce8d1b72098ae50ca48a2d83692eec25154ab5ba79d4b6b4fe8a9
|
|
@@ -39,7 +39,7 @@ referencing==0.37.0 --hash=sha256:381329a9f99628c9069361716891d34ad94af76e461dcb
|
|
|
39
39
|
rpds-py==2026.9.1 --hash=sha256:3f0e9ac28fc067d4d34b88ae43c48e9489455c97fee9633d851f7eeed5a05d35
|
|
40
40
|
scrapling==0.5.1 --hash=sha256:c9eb0ef22a05e00e19827a179544fea2bc91b663585f637d428453d3b00ceb17
|
|
41
41
|
six==1.17.0 --hash=sha256:4721f391ed90541fddacab5acf947aa0d3dc7d27b2e1e8eda2be8970586c3274
|
|
42
|
-
soupsieve==
|
|
42
|
+
soupsieve==4.1.3 --hash=sha256:7a390d1a57d1ab7bb228531e9b8a750a5ebf87db774e0ef6faeeac057d22a5bf
|
|
43
43
|
sse-starlette==3.6.0 --hash=sha256:e4dfa4d237d2712cb2b4d4918eda9b457cd6b44bbecdc838af75de836565bafd
|
|
44
44
|
starlette==1.10.0 --hash=sha256:478c0ab3b4ced6e82719849c118fa406f0278a3499c1a898cd15cd31bdc38ce4
|
|
45
45
|
tld==0.13.2 --hash=sha256:9b8fdbdb880e7ba65b216a4937f2c94c49a7226723783d5838fc958ac76f4e0c
|
package/py/search.py
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Scrapling 本身不是搜索引擎;这里只负责拿 URL 列表,正文渲染仍由 Host 侧的
|
|
4
4
|
search provider 交给本 sidecar 的 fetch/render。每条后端都按各家**文档里的**
|
|
5
|
-
|
|
5
|
+
请求与响应形状实现。Tavily 与 Bing 在本机打过真实端点;其余后端只有文档形状
|
|
6
|
+
与夹具,未在真实端点验证。
|
|
6
7
|
"""
|
|
7
8
|
|
|
8
9
|
from __future__ import annotations
|
|
@@ -478,7 +479,7 @@ def discover(args: dict[str, Any]) -> dict[str, Any]:
|
|
|
478
479
|
key = args.get("apiKey")
|
|
479
480
|
resolved = backend
|
|
480
481
|
if backend == "auto":
|
|
481
|
-
#
|
|
482
|
+
# auto 只挑「部署真的配好了的」后端。公共引擎回退
|
|
482
483
|
# (Bing)默认关闭,要部署显式打开 searchPublicFallback;否则这里必须报
|
|
483
484
|
# SEARCH_BACKEND_MISSING,而不是擅自把查询发给公共站点。
|
|
484
485
|
searxng_endpoint = args.get("searxngEndpoint")
|
package/py/session_page.py
CHANGED
|
@@ -97,8 +97,8 @@ def _number(value: Any) -> bool:
|
|
|
97
97
|
"""是不是一个真数字:`bool` 是 `int` 的子类,`True` 会被 `float()` 静默变成 1.0。
|
|
98
98
|
|
|
99
99
|
坐标与滚轮位移用这一条判据。传 `true` / `false` 是调用方明显的传参错误,静默成 1.0 / 0.0
|
|
100
|
-
等于替它做了一次带副作用的鼠标位移。同文件对 `wait_time.ms`
|
|
101
|
-
(`isinstance(ms, bool)
|
|
100
|
+
等于替它做了一次带副作用的鼠标位移。同文件对 `wait_time.ms` 也显式排除 `bool`
|
|
101
|
+
(`isinstance(ms, bool)`),两处判据同源。
|
|
102
102
|
"""
|
|
103
103
|
return isinstance(value, (int, float)) and not isinstance(value, bool)
|
|
104
104
|
|
package/runtime-manifest.json
CHANGED
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
"documents": {
|
|
12
12
|
"requirements": "py/documents-requirements.txt",
|
|
13
13
|
"distribution": "pypdf",
|
|
14
|
-
"version": "7.
|
|
15
|
-
"sha256": "
|
|
14
|
+
"version": "7.2.0",
|
|
15
|
+
"sha256": "de0b61a9023cb7ea8347d44e17d715f9064e91c7507d3646f86b282cd696e795"
|
|
16
16
|
},
|
|
17
17
|
"unsupported": {
|
|
18
18
|
"darwin-x64": "not verified on this host",
|