@jayyuen66/dsh-scrapling 0.1.1 → 0.1.2
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 +113 -0
- package/LICENSE +1 -1
- package/README.md +249 -551
- package/README.zh-CN.md +243 -399
- package/client.js +3 -1409
- package/host.js +28 -22
- package/package.json +41 -40
- package/py/adapters.py +48 -10
- package/py/bridge.py +18 -1
- package/py/crawl.py +39 -5
- package/py/guard.py +40 -7
package/README.md
CHANGED
|
@@ -1,361 +1,220 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
dsh
|
|
12
|
-
a
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://cdn.jsdelivr.net/gh/JayYuen666/dsh-scrapling@main/icon.svg" width="96" height="96" alt="dsh-scrapling logo" />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<h1 align="center">dsh-scrapling</h1>
|
|
6
|
+
|
|
7
|
+
<p align="center"><em>Scrapling web scraping for dsh: JavaScript rendering, structured extraction and a background crawler, behind one resident Python sidecar.</em></p>
|
|
8
|
+
|
|
9
|
+
<p align="center">
|
|
10
|
+
<a href="https://www.npmjs.com/package/@jayyuen66/dsh-scrapling"><img src="https://img.shields.io/npm/v/@jayyuen66/dsh-scrapling?style=flat-square&logo=npm&logoColor=white" alt="npm version" /></a>
|
|
11
|
+
<a href="https://www.npmjs.com/package/@jayyuen66/dsh-scrapling"><img src="https://img.shields.io/npm/dm/@jayyuen66/dsh-scrapling?style=flat-square" alt="npm downloads" /></a>
|
|
12
|
+
<a href="https://github.com/JayYuen666/dsh-scrapling/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/JayYuen666/dsh-scrapling/ci.yml?branch=main&style=flat-square&label=ci" alt="ci" /></a>
|
|
13
|
+
<img src="https://img.shields.io/badge/license-MIT-4c1?style=flat-square" alt="MIT" />
|
|
14
|
+
<img src="https://img.shields.io/badge/node-%3E%3D22.12-4c1?style=flat-square&logo=nodedotjs&logoColor=white" alt="node" />
|
|
15
|
+
<img src="https://img.shields.io/badge/dsh-%5E0.2.1--rc.3-658EFF?style=flat-square" alt="dsh" />
|
|
16
|
+
<a href="https://github.com/deepseek-ai/deepseek-harness"><img src="https://img.shields.io/badge/powered_by_dsh-4D6BFE?style=flat-square&logo=deepseek&logoColor=white" alt="powered by dsh" /></a>
|
|
17
|
+
</p>
|
|
18
|
+
|
|
19
|
+
<p align="center">
|
|
20
|
+
<img src="https://skillicons.dev/icons?i=typescript,python,react,nodejs,vitest,githubactions" alt="tech stack" />
|
|
21
|
+
</p>
|
|
22
|
+
|
|
23
|
+
<p align="center">
|
|
24
|
+
<a href="https://github.com/JayYuen666"><img src="https://img.shields.io/badge/GitHub-JayYuen666-181717?style=flat-square&logo=github&logoColor=white" alt="GitHub" /></a>
|
|
25
|
+
<a href="mailto:cqwkkj@gmail.com"><img src="https://img.shields.io/badge/Email-cqwkkj@gmail.com-EA4335?style=flat-square&logo=gmail&logoColor=white" alt="Email" /></a>
|
|
26
|
+
<a href="https://twitter.com/JayYuen666"><img src="https://img.shields.io/badge/Twitter-X%2FJayYuen666-000000?style=flat-square&logo=x&logoColor=white" alt="Twitter/X" /></a>
|
|
27
|
+
<a href="./README.zh-CN.md"><img src="https://img.shields.io/badge/lang-简体中文-658EFF?style=flat-square" alt="简体中文" /></a>
|
|
28
|
+
</p>
|
|
29
|
+
|
|
30
|
+
**A web-scraping extension for [dsh](https://github.com/deepseek-ai/deepseek-harness): [Scrapling](https://github.com/D4Vinci/Scrapling) as agent tools — JavaScript rendering, CSS/XPath extraction with self-healing selectors, sessions with login state, a background crawler and page Q&A. You supply the interpreter and the browser engine; everything runs in one resident Python process.**
|
|
31
|
+
|
|
32
|
+
## <img src="https://api.iconify.design/lucide/file-text.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> Contents
|
|
33
|
+
|
|
34
|
+
- [What it does](#what-it-does)
|
|
35
|
+
- [Install](#install)
|
|
36
|
+
- [Verify it is live](#verify-it-is-live)
|
|
37
|
+
- [What it does not provide](#what-it-does-not-provide)
|
|
38
|
+
- [Enabling it in dsh](#enabling-it-in-dsh)
|
|
39
|
+
- [The tools](#the-tools)
|
|
40
|
+
- [Replacing the built-in fetch and search](#replacing-the-builtin-fetch-and-search)
|
|
41
|
+
- [Settings](#settings)
|
|
42
|
+
- [Proxies](#proxies)
|
|
43
|
+
- [Security](#security)
|
|
44
|
+
- [Data and privacy](#data-and-privacy)
|
|
45
|
+
- [Known boundaries](#known-boundaries)
|
|
46
|
+
- [FAQ](#faq)
|
|
47
|
+
- [Development](#development)
|
|
48
|
+
- [License](#license)
|
|
49
|
+
|
|
50
|
+
## <img src="https://api.iconify.design/lucide/shield.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> What it does
|
|
51
|
+
|
|
52
|
+
dsh ships `web_fetch` and `web_search`. The built-in `web_fetch` is deliberately honest and minimal: a plain HTTP(S) GET with no JavaScript execution and an honest User-Agent. That is a good default — and it means a single-page application yields only its loading shell, and there is no way to ask for "just the product table". Measured on a page whose content exists only after JavaScript runs:
|
|
19
53
|
|
|
20
54
|
| Pipeline | Text obtained |
|
|
21
55
|
|---|---|
|
|
22
56
|
| raw HTML to text (no JS) | `SPA Shell / LOADING_PLACEHOLDER` |
|
|
23
57
|
| `Fetcher` (curl_cffi, still no JS) | `SPA Shell / LOADING_PLACEHOLDER` |
|
|
24
|
-
|
|
|
58
|
+
| browser render (patchright) | full rendered DOM, Markdown table, structured rows |
|
|
25
59
|
|
|
26
|
-
This
|
|
60
|
+
This package adds what the built-ins structurally cannot do:
|
|
27
61
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
the site's markup changes. Verified working: a selector that returns `None` after a
|
|
32
|
-
class rename returns the relocated element when `adaptive=True`.
|
|
62
|
+
- **Browser rendering** — JavaScript execution via patchright.
|
|
63
|
+
- **Structured extraction** — CSS/XPath selection returning data, not a wall of Markdown.
|
|
64
|
+
- **Self-healing selectors** — Scrapling's `adaptive` mode relocates an element after the site's markup changes; a selector that returns `None` after a class rename returns the relocated element with `adaptive` on.
|
|
33
65
|
|
|
34
|
-
|
|
66
|
+
Everything runs against **one long-lived Python process**. That is not an optimisation: Scrapling's session classes keep cookies, the browser engines keep a page pool, and `adaptive` keeps a SQLite fingerprint database — a process per call would throw all of that away. Tools are registered **conditionally**: the plugin probes what the environment can actually do at startup and registers only what will work, so the model never burns a turn on a tool that was guaranteed to fail. Every tool renders its result row through the official tool-call view slot. `scrapling_answer` is the only tool that spends **another model call** — see [The tools](#the-tools).
|
|
35
67
|
|
|
36
|
-
|
|
37
|
-
exercised by the test suite. Tools
|
|
38
|
-
are registered **conditionally**: the plugin probes what the environment can actually
|
|
39
|
-
do at startup and only registers tools that will work, so the model never burns a
|
|
40
|
-
turn on a tool that was guaranteed to fail.
|
|
68
|
+
## <img src="https://api.iconify.design/lucide/package.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> Install
|
|
41
69
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
`scrapling_answer` is the only tool that spends **another model call**: it fetches the page
|
|
53
|
-
first, then hands the text plus your question to a model and returns the conclusion instead
|
|
54
|
-
of the whole page. By default it follows **the model the current session is already using**
|
|
55
|
-
(read from the session's live request header, so a mid-session model switch is picked up),
|
|
56
|
-
which means the plugin does not burn a separate quota; you can pin `answerProvider` /
|
|
57
|
-
`answerModel` on the settings card to route page-reading to a different model.
|
|
58
|
-
|
|
59
|
-
Page text is **untrusted input** — a page can say "ignore your previous instructions". The
|
|
60
|
-
answer prompt frames the text explicitly as data and forbids acting on it, but that defence
|
|
61
|
-
is prompt-level: it lowers the risk, it does not remove it.
|
|
62
|
-
|
|
63
|
-
Everything runs against **one long-lived Python process**. That is not an
|
|
64
|
-
optimisation — Scrapling's session classes keep cookies, the browser engines keep a
|
|
65
|
-
page pool, and `adaptive` keeps a SQLite fingerprint database. A process per call
|
|
66
|
-
would throw all of that away.
|
|
67
|
-
|
|
68
|
-
`scrapling_crawl` returns a **job id immediately** rather than blocking: a crawl takes
|
|
69
|
-
minutes, a tool call has a timeout. Watch it with `job_list`, read it with
|
|
70
|
-
`job_output`, stop it with `job_kill`. A crawl also has a wall-clock ceiling
|
|
71
|
-
(`crawlMaxRuntimeSeconds`) and never leaves the start domain. Politeness is the
|
|
72
|
-
deployment's call, stated in the open: it is configured through the deployment knobs
|
|
73
|
-
(`crawlRespectRobots`, `crawlDownloadDelayMs`, `crawlConcurrentRequests`,
|
|
74
|
-
`crawlAutothrottle`, `crawlStrategy`, `crawlCheckpointDir`), and **their defaults keep
|
|
75
|
-
Scrapling's spider defaults** — robots.txt is **not** obeyed, per-domain delay is 0,
|
|
76
|
-
and up to 4 requests run in parallel. The crawl is confined to the start domain, so it
|
|
77
|
-
never fans out across unrelated sites; a target that needs gentler behaviour is a
|
|
78
|
-
deployment decision, not a per-call one.
|
|
79
|
-
|
|
80
|
-
## Requirements
|
|
81
|
-
|
|
82
|
-
- **Python 3.14+** with Scrapling installed, in the repo's `_env/.venv` or reachable via
|
|
83
|
-
`PATH` (or set `pythonBin`). The chosen interpreter is logged at load time.
|
|
84
|
-
- **Browser engines are entirely the user's responsibility.** The plugin does not
|
|
85
|
-
download anything. Without a browser it simply does not register the
|
|
86
|
-
browser-dependent tools, so the model never wastes a turn calling them.
|
|
70
|
+
```sh
|
|
71
|
+
dsh plugin --profile web add @jayyuen66/dsh-scrapling
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Remove with `dsh plugin --profile web remove @jayyuen66/dsh-scrapling`. The package is on the public npm registry, so installation needs no credentials and no scoped-registry line.
|
|
75
|
+
|
|
76
|
+
- **Requires Node.js `>= 22.12`.** This is an ESM-only package; that Node floor is what makes `require()` of an ESM entry work at all, which is why `engines.node` is declared.
|
|
77
|
+
- **Requires host `dsh` at the `0.2.1-rc.3` line.** The requirement the host actually reads is `engines.dsh` (`^0.2.1-rc.3`), and it decides alone; a host on a later line is refused and needs the explicit risk grant `dsh plugin --profile <p> allow-version <pkg>@<ver> --dsh-version <exact> --accept-risk`.
|
|
78
|
+
- **Requires Python 3.14+ with Scrapling installed** — in the repository's `_env/.venv`, or reachable from `PATH`, or named by `pythonBin`. In an installed package the `_env/.venv` leg does not exist, so the interpreter is the `python3` on your `PATH`; whichever one is chosen is logged at load time, and a missing Scrapling reports an error carrying the install line to copy.
|
|
87
79
|
|
|
88
80
|
```sh
|
|
89
81
|
pip install "scrapling[rag]>=0.5,<0.6"
|
|
90
82
|
python -m patchright install chromium
|
|
91
83
|
```
|
|
92
84
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
> **Version range**: this plugin is developed and verified against Scrapling **0.5**
|
|
99
|
-
> and depends on its `Convertor._strip_noise_tags` / `_sanitize_for_ai`, `Selector`,
|
|
100
|
-
> `Spider` and `SessionManager` interfaces. None of those are stable API surface, so the
|
|
101
|
-
> upper bound is pinned below `0.6`; outside the range the guards still run, but the
|
|
102
|
-
> anti-injection cleaning and the crawl path may not behave as documented.
|
|
103
|
-
|
|
104
|
-
> **What 0.5 breaks, and how this plugin follows it:**
|
|
105
|
-
> - **The browser backend is patchright only.** 0.5 removed the plain Playwright backend
|
|
106
|
-
> (`DynamicFetcher` / `DynamicSession`), so browser scraping is one code path. The old
|
|
107
|
-
> standalone `scrapling_stealth_fetch` is therefore **gone**: its anti-detection
|
|
108
|
-
> arguments now live on `scrapling_render`.
|
|
109
|
-
> - **`capture_xhr` became session-level recording.** A capture now records into a
|
|
110
|
-
> session, so this plugin adds `scrapling_session_network` to read what an open session
|
|
111
|
-
> has accumulated; `scrapling_capture_xhr` itself opens a throwaway session for one page.
|
|
112
|
-
> - **`extra_flags` is additive now, not replacing.** Upstream made `config.extra_flags`
|
|
113
|
-
> *stack on top of* the built-in anti-detection flags instead of replacing them, so the
|
|
114
|
-
> old "passing `extra_flags` silently wipes the whole stealth stack" invariant no longer
|
|
115
|
-
> holds. This plugin sends **no** `extra_flags` at all, and WebRTC leak protection is
|
|
116
|
-
> carried by the `block_webrtc` switch itself.
|
|
117
|
-
|
|
118
|
-
## Install
|
|
85
|
+
- **Why `rag` and not `fetchers`:** `rag` is `fetchers` plus `markdownify`, and the default `extractionType` is `markdown` — with plain `fetchers` the first fetch raises `ModuleNotFoundError` at the Markdown conversion.
|
|
86
|
+
- **Version range:** developed and verified against Scrapling **0.5**, through interfaces that are not stable API surface (`Selector`, `Spider`, `SessionManager`, and the converter's noise-stripping helpers). The upper bound is pinned below `0.6`; outside the range the guards still run, but the anti-injection cleaning and the crawl path may not behave as documented. In 0.5 the browser backend is patchright only (the old standalone stealth fetch is gone; its anti-detection arguments live on `scrapling_render`), `capture_xhr` became session-level recording (hence `scrapling_session_network`), and `extra_flags` became additive — this package sends none, and WebRTC leak protection is carried by the `blockWebrtc` switch.
|
|
87
|
+
- **Browser engines are entirely your responsibility.** The plugin downloads nothing. Without a browser it simply does not register the browser-dependent tools, so the model never wastes a turn calling them.
|
|
88
|
+
- **No `@deepseek-ai/*` under `dependencies`, by contract** (`test/publish-manifest.test.ts` enforces it). Consumer profiles install with `nodeLinker: hoisted` and `autoInstallPeers: false`, so a host package there becomes a real second copy whose module-level state splits from the running host's — every native tool call then throws while build and tests stay green. The host packages the artifact imports for value are required peers and stay externalized; the gate imports the built artifact and asserts that no host package body is inlined.
|
|
89
|
+
- **The artifact is ESM-only and never committed** — `prepack` rebuilds it, so what ships is always what the current source produces.
|
|
119
90
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
91
|
+
### <img src="https://api.iconify.design/lucide/arrow-down-to-line.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> Shared version floor
|
|
92
|
+
|
|
93
|
+
If your profile pins `@jayyuen66/dsh-plugin-shared` with a pnpm `overrides` entry, that pin must be at least the version this package declares. A lower pin installs a copy without the names the sources use, and the host then reports `N entries did not activate` together with `does not provide an export named ...` at boot - the package installs fine and never loads, and no per-repository CI run can see it.
|
|
123
94
|
|
|
124
|
-
|
|
95
|
+
## <img src="https://api.iconify.design/lucide/circle-check.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> Verify it is live
|
|
125
96
|
|
|
97
|
+
1. **The layer is mounted.** `dsh --profile web --dump-config` shows this package's layer line.
|
|
98
|
+
- That command is the only accepted "it is in the layer stack" signal, and it is **not read-only** — it rewrites the profile's root assembly file. Read layer lines from stdout **and** check stderr separately: an unmatched patch target appears only on stderr, so the exit code alone proves nothing. Accept both `# == <layer>` and `# == <layer>, patched by <path>`.
|
|
99
|
+
2. **The startup log names the interpreter and the plan.** One line prints the probed capabilities and how many of the tools registered; the chosen interpreter path is logged at load. An interpreter that starts but lacks Scrapling is named in the log together with the pip line to copy.
|
|
100
|
+
3. **The settings card renders.** The plugin detail page carries the **scrapling** card with every user-editable field grouped by purpose; toggling a value enables Save, and the write returns 200.
|
|
101
|
+
4. **A tool round-trip.** Ask the model to fetch a JavaScript-heavy page: the result row renders in the chat through the official tool-call view. On a machine without a browser the render / capture_xhr tools are absent from the model's tool list and their prompt guidance is gone too — that absence is the conditional registration working, not a failure.
|
|
126
102
|
|
|
127
|
-
##
|
|
103
|
+
## <img src="https://api.iconify.design/lucide/circle-slash.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> What it does not provide
|
|
128
104
|
|
|
129
|
-
|
|
105
|
+
- **It is not a search engine.** Scrapling only sets a Google referer header for its `google_search` option; discovery needs a deployment-level `searchEndpoint` (see [Settings](#settings)). Without one the search provider stays unavailable and the built-in `web_search` keeps its behaviour.
|
|
106
|
+
- **It downloads nothing.** The Python interpreter and the browser engine are supplied by you; missing pieces remove the matching tools instead of being fetched.
|
|
107
|
+
- **It opens no HTTP route of its own.** The settings card is a host config form; there is no `/api` surface from this package.
|
|
108
|
+
- **It adds no CLI subcommand.**
|
|
130
109
|
|
|
131
|
-
##
|
|
110
|
+
## <img src="https://api.iconify.design/lucide/plug.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> Enabling it in dsh
|
|
132
111
|
|
|
133
|
-
|
|
134
|
-
`
|
|
135
|
-
|
|
136
|
-
|
|
112
|
+
- `dsh.bundle.patch` points at `cordis.patch.yml`, whose single registration line is `- id: scrapling` with the **bare package name** — the host scans `dsh.client` on bare package-name entries only.
|
|
113
|
+
- The client half registers two surfaces: the settings card (on the `plugins.bundle.config` slot, keyed by the bundle package name — the host dispatches `entryKey: pkg.name`, so the card renders on this package's detail page) and one result row per tool on `tool.call.toolview`, drawn with the official tool-call view props.
|
|
114
|
+
- The settings namespace is the entry id `scrapling`; precedence is settings-card value > registration-line `config:` > schema default. Setting a field back to its default saves a **clear-override**, not a write of the same value, so a later default change still reaches you.
|
|
115
|
+
- Gate policy and the sidecar environment are snapshotted once when the plugin is applied — **settings changes take effect on the next start**.
|
|
116
|
+
- Disabling a tool also removes its system-prompt guidance: the guidance is re-read at each prompt assembly against the tools that scope can actually see, so a machine without a browser loses the render / capture_xhr lines and a sidecar that never came up loses all of them. The section is placed next to the built-in `web_fetch` guidance.
|
|
117
|
+
- `scrapling_crawl` registers its own job kind, so `job_list` labels its jobs as crawls rather than shell jobs.
|
|
137
118
|
|
|
138
|
-
|
|
139
|
-
> `NamedEntries.insert`, which **throws** on a duplicate name
|
|
140
|
-
> (`tool "X" is already registered`). Registering a same-named tool is therefore closed off;
|
|
141
|
-
> the `ctx.web` provider seam is the supported replacement channel.
|
|
119
|
+
## <img src="https://api.iconify.design/lucide/globe.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> The tools
|
|
142
120
|
|
|
143
|
-
|
|
144
|
-
both providers whenever the sidecar is up. That still does **not** take over the built-in
|
|
145
|
-
tools on its own: the deployment config has to name the provider.
|
|
121
|
+
Thirteen tools, each behind one settings switch, all exercised by the test suite:
|
|
146
122
|
|
|
147
|
-
|
|
123
|
+
| Tool | Backend | Needs a browser | Concurrency |
|
|
124
|
+
|---|---|---|---|
|
|
125
|
+
| `scrapling_fetch` | `Fetcher` (curl_cffi) | no | concurrent; write verbs are serialised once `allowWriteMethods` is on |
|
|
126
|
+
| `scrapling_extract` | `Selector` + CSS/XPath + `adaptive` | no | concurrent |
|
|
127
|
+
| `scrapling_render` | `StealthySession` (patchright) | yes | serialised; the anti-detection switches (`solveCloudflare` / `hideCanvas` / `blockWebrtc`) live here |
|
|
128
|
+
| `scrapling_capture_xhr` | one throwaway session, page-level recording | yes | serialised |
|
|
129
|
+
| `scrapling_session_open` / `scrapling_session_fetch` / `scrapling_session_network` / `scrapling_session_state_save` / `scrapling_session_state_load` / `scrapling_session_list` / `scrapling_session_close` | Scrapling session classes | browser sessions only | serialised |
|
|
130
|
+
| `scrapling_crawl` | Scrapling Spider framework, runs as a job | no | serialised |
|
|
131
|
+
| `scrapling_answer` | any fetch path plus `ctx.llm` | with `render: true` | serialised |
|
|
132
|
+
|
|
133
|
+
- **Quotas.** At most 8 open sessions (3 of them browser sessions, each a real Chromium process), 2 crawls in flight, per-page bodies clipped by `*MaxOutputChars`, 8 MB per protocol frame, 16 queued frames. A ceiling answers with a specific code (`SESSION_LIMIT` / `CRAWL_BUSY` / `BAD_FRAME`) the model can back off from.
|
|
134
|
+
- **`scrapling_crawl` returns a job id immediately** — a crawl takes minutes and a tool call has a timeout. Watch it with `job_list`, read it with `job_output`, stop it with `job_kill`; the tool needs a jobs registry that can attach a controller, and a profile without one simply does not register it (single-page fetching is unaffected). The crawl has a wall-clock ceiling (`crawlMaxRuntimeSeconds`) and never leaves the start domain. Politeness defaults follow Scrapling's spider defaults — robots.txt is **not** obeyed, per-domain delay is 0, up to 4 requests run in parallel — and is a deployment decision, not a per-call one (see [Settings](#settings)).
|
|
135
|
+
- **`scrapling_answer` fetches the page first, then hands the text plus your question to a model** and returns the conclusion instead of the whole page. It follows the model the current session is already using by default (read from the session's live request header, so a mid-session model switch is picked up), which burns no separate quota; pin `answerProvider` / `answerModel` to route page-reading elsewhere. Page text is **untrusted input** — the prompt frames it explicitly as data, but that defence is prompt-level: it lowers the risk, it does not remove it.
|
|
136
|
+
|
|
137
|
+
### Render or static
|
|
138
|
+
|
|
139
|
+
`scrapling_render` is much slower and heavier than `scrapling_fetch`, so start static. Two criteria:
|
|
140
|
+
|
|
141
|
+
- **If the rendered result is shorter than the static fetch, go back to static.** Plenty of sites ship readable text from the server and then have their own script empty those containers and swap in canvas / Lottie animation — for those pages rendering can only lose content, and no wait setting brings it back. That is site behaviour, not a plugin defect.
|
|
142
|
+
- **`waitSelector` waits for an element to appear, not for content to settle.** The element can be removed after it matched, so "the selector matched" does not mean the content is in the result.
|
|
143
|
+
|
|
144
|
+
One thing that is not a criterion but worth knowing: axis ticks inside SVG **cannot be fetched at all** — the Markdown conversion emits no `<svg>` / `<text>` nodes, so chart numbers are out of reach whichever tool you use. For actual values, go through `scrapling_capture_xhr` to locate the JSON endpoint.
|
|
145
|
+
|
|
146
|
+
## <img src="https://api.iconify.design/lucide/arrow-right-left.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> Replacing the built-in fetch and search
|
|
147
|
+
|
|
148
|
+
The plugin registers itself as a **fetch provider** and a **search provider** on `ctx.web`, so the built-in `web_fetch` / `web_search` tools actually run on Scrapling instead of dsh's plain-HTTP implementation. The model still calls `web_fetch` / `web_search` — tool names cannot be swapped (same-name registration throws), the provider seam is the supported channel. Both providers are registered by default (`provideWebFetch` / `provideWebSearch`), but that alone displaces nothing:
|
|
149
|
+
|
|
150
|
+
1. leave `provideWebFetch` / `provideWebSearch` at their default (`true`);
|
|
148
151
|
2. set `fetchProvider` / `searchProvider` to `"scrapling"` in the **deployment** config.
|
|
149
152
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
- **
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
`networkEnabled` / `sessionEnabled` / `sessionStateEnabled` / `crawlEnabled` /
|
|
208
|
-
`answerEnabled` - on by default.
|
|
209
|
-
`scrapling_crawl` needs a profile that ships a jobs backend; without one it fails
|
|
210
|
-
loudly (`JOBS_UNAVAILABLE`) rather than silently doing nothing. `sessionStateEnabled`
|
|
211
|
-
controls the `scrapling_session_state_save` / `scrapling_session_state_load` pair, and
|
|
212
|
-
those need a deployment-side `sessionStateDir` to be usable.
|
|
213
|
-
- `pierceShadow` - **off** by default: it merges the contents of open shadow roots into
|
|
214
|
-
the body. A page that hides its text in shadow DOM is invisible to a plain HTML read,
|
|
215
|
-
so this is the switch for those; the model can also override it per call on the
|
|
216
|
-
browser tools.
|
|
217
|
-
- `extractionType` - `markdown` (default), `html` or `text`. All three paths run the
|
|
218
|
-
same anti-injection cleaning; `html` additionally strips event-handler attributes
|
|
219
|
-
(`on*`, `srcdoc`, `formaction`) and `meta refresh`, so the result is **not**
|
|
220
|
-
byte-for-byte raw HTML.
|
|
221
|
-
- `*MaxOutputChars` - per-tool output caps. The host-side cap only governs what reaches
|
|
222
|
-
the model context; the sidecar clips first by `maxContentChars` (characters) and the
|
|
223
|
-
host then trims to a byte budget. `crawlMaxItems` is the deployment-side
|
|
224
|
-
ceiling over the model-supplied `maxPages`; an out-of-range `maxPages` (0, negative,
|
|
225
|
-
NaN) is passed through unchanged so the sidecar reports the parameter error rather
|
|
226
|
-
than this plugin silently clamping it into a legal-looking value.
|
|
227
|
-
`crawlMaxRuntimeSeconds` is the crawl's wall-clock ceiling: the page cap says nothing
|
|
228
|
-
about a site that takes a minute per page, and a crawl is a background thread nobody
|
|
229
|
-
is watching. On expiry the spider winds down through its own stop channel instead of
|
|
230
|
-
running until the site runs out.
|
|
231
|
-
- `stripInlineImages` - **on** by default: inline `data:` URI images are dropped from
|
|
232
|
-
the body and only their alt text is kept. Such an image is pure token noise - a
|
|
233
|
-
base64 SVG costs characters in the context while the model cannot read a shape out
|
|
234
|
-
of it. Pages with no inline images come back **byte-identical**; where there are some, the
|
|
235
|
-
saving depends entirely on how many - a site either inlines none or inlines a whole wall of
|
|
236
|
-
logos, and little in between. So turning this on is free for pages without inline images, and
|
|
237
|
-
the whole benefit lands when it matches.
|
|
238
|
-
`data:` URIs inside code fences are left untouched - there they are almost always
|
|
239
|
-
sample code a tutorial is teaching, and stripping would be editing the document.
|
|
240
|
-
Turn this off only when the raw base64 *is* the data (colours, fingerprints).
|
|
241
|
-
Stripping happens **before** the cap: the other way round is pointless, since those
|
|
242
|
-
tens of kilobytes have already eaten the `maxContentChars` budget.
|
|
243
|
-
- `answerProvider` / `answerModel` / `answerMaxTokens` - the model `scrapling_answer`
|
|
244
|
-
routes to and the per-call token ceiling. Provider and model left empty mean "follow
|
|
245
|
-
the model the current session is already using"; `answerMaxTokens` caps the reply.
|
|
246
|
-
- `mainContentOnly` / `headless` / `networkIdle` / `waitSelectorState` / `dataDir` -
|
|
247
|
-
extraction scope, browser mode, the selector state a page must reach before it is read,
|
|
248
|
-
and the sidecar working directory. Each is documented at its declaration in
|
|
249
|
-
[`host.ts`](./host.ts).
|
|
250
|
-
- `sidecarHandshakeTimeoutMs` / `fetchTimeoutMs` / `sidecarGraceMs` - the budget for the
|
|
251
|
-
sidecar handshake, the per-call cooperative timeout (declared as the tools' `timeoutMs`), and
|
|
252
|
-
how long the client waits for the process to exit after that timeout before forcing it down.
|
|
253
|
-
The three are on the settings card. `scrapling_crawl` is the exception: it runs as a job and
|
|
254
|
-
passes no timeout, because a crawl is measured in minutes and a fixed budget would tear the
|
|
255
|
-
process down on every success.
|
|
256
|
-
- `failFastOnMissingPython` - `true` (default) refuses to load when the interpreter is
|
|
257
|
-
unusable, because every tool needs the sidecar and a silent degrade leaves the model
|
|
258
|
-
discovering "all tools are missing" several turns later. `false` degrades to "all
|
|
259
|
-
tools unavailable" with a warning.
|
|
260
|
-
- `blockAds` - on by default. It stacks **on top of** the SSRF guard rather than
|
|
261
|
-
competing with it: the guard is registered last (so Playwright runs it first) and
|
|
262
|
-
yields with `route.fallback()`, leaving Scrapling's own interception handler reachable.
|
|
263
|
-
- `allowedHosts` - extra host names that skip the public-address check. The same setting
|
|
264
|
-
feeds both layers, so an explicitly allowed intranet target is not rejected by the
|
|
265
|
-
host-side policy before the Python side ever sees it. Pointing it at an intranet
|
|
266
|
-
address means giving up SSRF protection for those targets on purpose.
|
|
267
|
-
- `syntheticDnsRanges` - manual fallback for synthetic DNS: a comma-separated CIDR list
|
|
268
|
-
of your proxy's fake-IP pool. Detection is the main path and should handle it; this is
|
|
269
|
-
for the case where the resolver mixes synthetic and real answers. Invalid entries are
|
|
270
|
-
dropped rather than refusing to load - this is a fallback, and a broken one degrades to
|
|
271
|
-
"stay strict", not to a crash.
|
|
272
|
-
- `proxyUrl` - where fetches go out, e.g. `http://127.0.0.1:7890` or
|
|
273
|
-
`socks5://127.0.0.1:7890`, optionally with `user:pass@`. **Empty means follow the
|
|
274
|
-
environment.** It is a deployment-level capability and never enters a tool schema. The
|
|
275
|
-
resolution order is spelled out under [Proxies](#proxies).
|
|
276
|
-
- `proxyBypass` - host names that should connect directly, mirroring `NO_PROXY`.
|
|
277
|
-
|
|
278
|
-
**Deployment-grade knobs** (not on the settings card; set them in the `config:` block of
|
|
279
|
-
`cordis.patch.yml`): `requestTimeoutSeconds`, `maxUrlLength`, `browserExecutablePath`,
|
|
280
|
-
`browserCdpUrl`, `browserInitScript`, `browserRealChrome`, `browserDnsOverHttps`,
|
|
281
|
-
`recordRequests`, `maxRecordedRequests`, `sessionStateDir`, `crawlMaxRuntimeSeconds`,
|
|
282
|
-
`crawlRespectRobots`, `crawlDownloadDelayMs`, `crawlConcurrentRequests`,
|
|
283
|
-
`crawlAutothrottle`, `crawlStrategy`, `crawlCheckpointDir`, `searchEndpoint`,
|
|
284
|
-
`searchRenderTopN`, `allowWriteMethods` (default `false`). The browser pair
|
|
285
|
-
(`browserExecutablePath`, `browserCdpUrl`) and `browserInitScript` are strong
|
|
286
|
-
capabilities - they hand Chromium a file to execute and the browser to a debugger
|
|
287
|
-
endpoint - so they come only from deployment config and are unreachable from model input.
|
|
288
|
-
`allowWriteMethods` is off by default for the same kind of reason: it decides whether the
|
|
289
|
-
model may change state on a remote host. The crawler knobs and `sessionStateDir` are
|
|
290
|
-
deployment decisions too - see
|
|
291
|
-
[Sessions, network history and crawler etiquette](#sessions-network-history-and-crawler-etiquette).
|
|
292
|
-
|
|
293
|
-
> **Settings changes need a dsh restart.** The gate policy and the sidecar environment are
|
|
294
|
-
> snapshotted once when the plugin is applied; edits on the settings card take effect on the
|
|
295
|
-
> next start.
|
|
296
|
-
|
|
297
|
-
Disabling a tool also removes its system-prompt guidance, so the model is never told
|
|
298
|
-
about a capability that is not registered. The guidance is re-read at each prompt
|
|
299
|
-
assembly against the tools that scope can actually see, so a machine without a browser
|
|
300
|
-
loses the render / capture_xhr lines, and a sidecar that never came up loses all of them -
|
|
301
|
-
advice to call a missing tool costs a round trip and a confusing `UNKNOWN_TOOL`.
|
|
302
|
-
|
|
303
|
-
## Sessions, network history and crawler etiquette
|
|
304
|
-
|
|
305
|
-
Scrapling 0.5 exposes a few capabilities that this plugin surfaces as tools, each with a
|
|
306
|
-
deployment knob beside it. The tools are on the settings card; the knobs are
|
|
307
|
-
deployment-only (the `config:` block of `cordis.patch.yml`).
|
|
308
|
-
|
|
309
|
-
- **Network history.** An open session can record the XHR/fetch requests it makes.
|
|
310
|
-
`recordRequests` is the deployment default, and the model can turn recording on for one
|
|
311
|
-
session with `recordNetwork` on `scrapling_session_open`. Read it back with
|
|
312
|
-
`scrapling_session_network` (`urlPattern` / `includeBody` / `networkLimit` /
|
|
313
|
-
`maxBodyChars`); `maxRecordedRequests` caps how many entries a session keeps. A session
|
|
314
|
-
that is not recording reports an error rather than an empty list.
|
|
315
|
-
- **Shadow DOM.** `pierceShadow` merges open shadow roots into the body (off by default);
|
|
316
|
-
the model can also override it per call on the browser tools.
|
|
317
|
-
- **Login state.** `sessionStateDir` points at a directory for Playwright-compatible
|
|
318
|
-
login-state files. `scrapling_session_state_save` / `scrapling_session_state_load` write
|
|
319
|
-
and read them; the model can only pass a **plain file name** (no path), so the directory
|
|
320
|
-
stays a deployment decision. Empty means the pair is disabled.
|
|
321
|
-
- **Crawler etiquette and order.** `crawlRespectRobots` (off by default) makes the spider
|
|
322
|
-
obey robots.txt; with it on, a domain whose robots.txt cannot be fetched is **blocked**
|
|
323
|
-
rather than assumed permitted. `crawlDownloadDelayMs` (`0`) sets the gap between
|
|
324
|
-
requests, `crawlConcurrentRequests` (`4`) the parallelism, `crawlAutothrottle` (off) lets
|
|
325
|
-
the spider slow itself down, and `crawlStrategy` (`bfs` / `dfs`) picks breadth- or
|
|
326
|
-
depth-first.
|
|
327
|
-
- **Crawl checkpoints.** `crawlCheckpointDir` (empty) lets a crawl persist its queue, so a
|
|
328
|
-
restarted crawl resumes instead of going back to the start URL.
|
|
329
|
-
- **Browser extras.** `browserInitScript` injects a JS file into every page (a strong
|
|
330
|
-
capability), `browserRealChrome` uses the locally-installed Google Chrome instead of the
|
|
331
|
-
bundled Chromium, and `browserDnsOverHttps` routes the browser's DNS over HTTPS (useful
|
|
332
|
-
with a proxy to avoid DNS leaks).
|
|
333
|
-
|
|
334
|
-
## Proxies
|
|
335
|
-
|
|
336
|
-
Where a fetch goes out, resolved in this order - **first hit wins**:
|
|
153
|
+
A configured id wins over auto-selection, which is why step 2 is required — and with two usable providers and no id named, `ctx.web` answers `WEB_PROVIDER_AMBIGUOUS` and the tool becomes unavailable outright. Two consequences of pointing that line at this plugin:
|
|
154
|
+
|
|
155
|
+
- **If the sidecar cannot start, the built-in `web_fetch` reports `WEB_PROVIDER_CONFIGURED_UNAVAILABLE`** rather than quietly falling back to plain HTTP.
|
|
156
|
+
- **If you later remove the plugin but leave the line in**, the built-in tools report `WEB_PROVIDER_CONFIGURED_MISSING` — go back and remove `fetchProvider` / `searchProvider` too.
|
|
157
|
+
- **The fetch provider really applies the output budget**: a body over `fetchMaxOutputChars` is cut to a head/tail window and flagged `truncated`, not passed through with a flag. Failures keep the sidecar code prefix (`URL_BLOCKED`, `SIDECAR_TIMEOUT`, `SIDECAR_UNAVAILABLE`), so a policy refusal is distinguishable from a crash or a timeout.
|
|
158
|
+
|
|
159
|
+
Search is split in two, because Scrapling is not a search engine: **discovery** goes to a deployment-level `searchEndpoint`, expected to be SearXNG-compatible JSON (`GET <endpoint>?q=<query>&format=json` returning `{"results": [{"url", "title", "content"}]}` — any backend producing that shape works); **reading** is this plugin's — the first `searchRenderTopN` results are actually fetched and, with a browser, rendered, so one `web_search` call returns both which pages matter and what they say. Every returned URL goes through the same gate as a fetch; a page that fails to read is skipped alone, because search results routinely contain dead links.
|
|
160
|
+
|
|
161
|
+
One consequence to know: `dsh-web`'s fetch body is a **closed** union of `html | text` with no `markdown` kind, and adding one is a cross-package change a plugin cannot make. The fetch provider therefore reports Scrapling's Markdown as `text`, which the built-in renderer displays normally. Use `scrapling_fetch` directly when you need `html` or a CSS selector.
|
|
162
|
+
|
|
163
|
+
## <img src="https://api.iconify.design/lucide/sliders-horizontal.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> Settings
|
|
164
|
+
|
|
165
|
+
Settings live on the **scrapling** card in the plugin detail page, grouped by purpose, each field with a one-line "what changes if you edit this". The card's language follows the host locale. Values marked below live on the card; the deployment table after them is only settable through the `config:` block of `cordis.patch.yml`.
|
|
166
|
+
|
|
167
|
+
| Field | Type | Default | Purpose |
|
|
168
|
+
| --- | --- | --- | --- |
|
|
169
|
+
| `pythonBin` | string | `""` | Interpreter name or absolute path. Empty = the repository `_env/.venv` when executable, otherwise `python3` on `PATH` |
|
|
170
|
+
| `failFastOnMissingPython` | boolean | `true` | Refuses to load when the sidecar process cannot start (wrong path, protocol mismatch, handshake timeout). An interpreter that starts but lacks Scrapling always degrades to "tools unavailable" with the path named in the log, whatever this switch says |
|
|
171
|
+
| `fetchEnabled` / `extractEnabled` / `renderEnabled` / `captureXhrEnabled` / `networkEnabled` / `sessionEnabled` / `sessionStateEnabled` / `crawlEnabled` / `answerEnabled` | boolean | `true` | One kill switch per tool or tool pair. `sessionStateEnabled` gates the state save / load pair, which also needs a deployment-side `sessionStateDir` |
|
|
172
|
+
| `extractionType` | enum | `markdown` | `markdown` / `html` / `text`; all three run the same anti-injection cleaning, and `html` additionally strips event-handler attributes, so it is not byte-for-byte raw HTML |
|
|
173
|
+
| `mainContentOnly` | boolean | `true` | Extraction scope |
|
|
174
|
+
| `*MaxOutputChars` | natural | fetch / extract / render `200000`, xhr `120000` | Per-tool output caps. The sidecar clips by characters, the host then trims to a byte budget |
|
|
175
|
+
| `crawlMaxItems` | natural | `1000` | Ceiling over the model-supplied `maxPages`. An out-of-range `maxPages` is passed through so the sidecar reports the parameter error rather than this plugin silently clamping it |
|
|
176
|
+
| `stripInlineImages` | boolean | `true` | Drops inline `data:` URI images from the body, keeping only alt text — pure token noise for the model. Code fences are left untouched; pages without inline images come back byte-identical. Stripping happens before the cap. Turn off only when the raw base64 **is** the data (colours, fingerprints) |
|
|
177
|
+
| `headless` / `networkIdle` | boolean | `true` / `false` | Browser mode and whether a page must reach network idle before it is read |
|
|
178
|
+
| `blockAds` | boolean | `true` | Stacks **on top of** the SSRF guard rather than competing with it: the guard is registered last (so the engine runs it first) and yields with `route.fallback()` |
|
|
179
|
+
| `pierceShadow` | boolean | `false` | Merges open shadow roots into the body — the switch for pages that hide their text in shadow DOM. The model can also override it per call on the browser tools |
|
|
180
|
+
| `waitSelectorState` | enum | `attached` | The state a `waitSelector` element must reach (`attached` / `detached` / `hidden` / `visible`) |
|
|
181
|
+
| `sidecarHandshakeTimeoutMs` / `fetchTimeoutMs` / `sidecarGraceMs` | natural | `30000` / `120000` / `5000` | Handshake budget, per-call cooperative timeout (declared on the tools' `timeoutMs`), and how long the client waits for the process to exit before forcing it down. `scrapling_crawl` passes no timeout — a crawl is measured in minutes |
|
|
182
|
+
| `dataDir` | string | `""` | Sidecar working directory (the `adaptive` fingerprint database lands here); empty = `~/.dsh-scrapling`. If it cannot be created, `failFastOnMissingPython` decides whether the plugin refuses to load or degrades to no tools |
|
|
183
|
+
| `provideWebFetch` / `provideWebSearch` | boolean | `true` | Whether the `ctx.web` providers are registered at all — see [Replacing the built-in fetch and search](#replacing-the-builtin-fetch-and-search) |
|
|
184
|
+
| `answerProvider` / `answerModel` / `answerMaxTokens` | string / natural | `""` / `""` / `2000` | The model `scrapling_answer` routes to and the per-reply token cap. Provider and model left empty mean "follow the model the current session is already using" |
|
|
185
|
+
| `allowedHosts` | string | `""` | Extra host names that skip the public-address check (comma-separated). Pointing it at an intranet address means giving up SSRF protection for those targets on purpose |
|
|
186
|
+
| `syntheticDnsRanges` | string | `""` | Manual fallback for synthetic DNS: a comma-separated CIDR list of your proxy's fake-IP pool, for resolvers that mix synthetic and real answers. Invalid entries are dropped — a broken fallback degrades to "stay strict", not to a crash |
|
|
187
|
+
| `proxyUrl` | string | `""` | Where fetches go out (`http://…` / `socks5://…`, optionally `user:pass@`). Empty = follow the environment; see [Proxies](#proxies). Masked on the card, never enters a tool schema |
|
|
188
|
+
| `proxyBypass` | string | `""` | Host names that connect directly, mirroring `NO_PROXY`; `*` means the whole machine goes direct |
|
|
189
|
+
| `nat64Prefixes` | string | `""` | Extra NAT64 prefixes (comma-separated CIDRs) for operator-specific networks; a declared prefix applies to every IPv6 address |
|
|
190
|
+
|
|
191
|
+
**Deployment-only knobs** (not on the card; set them in the `config:` block of `cordis.patch.yml`):
|
|
192
|
+
|
|
193
|
+
| Field | Default | Purpose |
|
|
194
|
+
| --- | --- | --- |
|
|
195
|
+
| `requestTimeoutSeconds` / `maxUrlLength` | `120` / `2048` | Python-side per-request ceiling; URL length cap aligned with the built-in fetch |
|
|
196
|
+
| `allowWriteMethods` | `false` | Whether the model may change state on a remote host at all — see [Security](#security) |
|
|
197
|
+
| `browserExecutablePath` / `browserCdpUrl` / `browserInitScript` | `""` | Strong capabilities: they hand Chromium a file to execute and the browser to a debugger endpoint, or inject a JS file into every page. Deployment config only, unreachable from model input |
|
|
198
|
+
| `browserRealChrome` / `browserDnsOverHttps` | `false` | Use the locally installed Google Chrome; route the browser's DNS over HTTPS (useful with a proxy to avoid DNS leaks) |
|
|
199
|
+
| `recordRequests` / `maxRecordedRequests` | `false` / `100` | Whether browser sessions record network history by default (the model can turn it on per session with `recordNetwork`), and how many entries a session keeps |
|
|
200
|
+
| `sessionStateDir` | `""` | Directory for Playwright-compatible login-state files. The model can only pass a **plain file name**, so the directory stays a deployment decision; empty disables the state save / load pair |
|
|
201
|
+
| `crawlMaxRuntimeSeconds` | `1800` | Wall-clock ceiling of one crawl — the page cap says nothing about a site that takes a minute per page |
|
|
202
|
+
| `crawlRespectRobots` | `false` | Obey robots.txt; with it on, a domain whose robots.txt cannot be fetched is **blocked** rather than assumed permitted |
|
|
203
|
+
| `crawlDownloadDelayMs` / `crawlConcurrentRequests` / `crawlAutothrottle` / `crawlStrategy` | `0` / `4` / `false` / `bfs` | Gap between requests, parallelism, adaptive throttling, breadth- or depth-first order |
|
|
204
|
+
| `crawlCheckpointDir` | `""` | Persist the crawl queue so a restarted crawl resumes instead of going back to the start URL |
|
|
205
|
+
| `searchEndpoint` / `searchRenderTopN` | `""` / `3` | The SearXNG-compatible discovery backend, and how many of its results are actually fetched and rendered (`0` = link list only) |
|
|
206
|
+
|
|
207
|
+
## <img src="https://api.iconify.design/lucide/network.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> Proxies
|
|
208
|
+
|
|
209
|
+
Where a fetch goes out, resolved in this order — **first hit wins**:
|
|
337
210
|
|
|
338
211
|
1. `proxyBypass` or the environment's `NO_PROXY` matches this host -> direct.
|
|
339
212
|
2. `proxyUrl` on the settings card is non-empty -> use it.
|
|
340
|
-
3. `http_proxy` / `https_proxy` / `all_proxy` in the environment (upper case works too) ->
|
|
341
|
-
|
|
342
|
-
4. The operating system's proxy settings (`scutil --proxy` on macOS, Internet Settings on
|
|
343
|
-
Windows) -> use them.
|
|
213
|
+
3. `http_proxy` / `https_proxy` / `all_proxy` in the environment (upper case works too) -> use the matching slot.
|
|
214
|
+
4. The operating system's proxy settings (`scutil --proxy` on macOS, Internet Settings on Windows) -> use them.
|
|
344
215
|
5. Neither -> direct.
|
|
345
216
|
|
|
346
|
-
|
|
347
|
-
explicit intent; environment variables cover CI, ssh sessions and `docker exec`, where a
|
|
348
|
-
proxy is only ever `export`ed in the shell; the OS settings are what proxy clients default
|
|
349
|
-
to on macOS and Windows - flip "system proxy" on in Clash Verge or Surge and every browser
|
|
350
|
-
on the machine is proxied, while curl_cffi has no idea system settings exist.
|
|
351
|
-
|
|
352
|
-
An explicit `proxyUrl` makes the last two rungs irrelevant: an explicit setting should
|
|
353
|
-
outrank an implicit source, otherwise "I set 7890 and it still goes through 1080" has
|
|
354
|
-
nowhere to be debugged from. The bypass list cuts across everything above it - a hit
|
|
355
|
-
connects directly no matter where the proxy came from.
|
|
356
|
-
|
|
357
|
-
What that looks like in practice - **with or without a proxy, the tools just work, with no
|
|
358
|
-
setting to fill in**:
|
|
217
|
+
What that looks like in practice — **with or without a proxy, the tools just work, with no setting to fill in**:
|
|
359
218
|
|
|
360
219
|
| Your setup | Static fetching | Render / XHR |
|
|
361
220
|
| --- | --- | --- |
|
|
@@ -366,238 +225,77 @@ setting to fill in**:
|
|
|
366
225
|
| Intranet targets / internal Git | exclude with `proxyBypass` | exclude with `proxyBypass` |
|
|
367
226
|
| PAC (auto-config script) | not followed; stderr says to set `proxyUrl` | followed natively by the browser |
|
|
368
227
|
|
|
369
|
-
PAC is the one shape that still needs a hand-filled setting: evaluating it means
|
|
370
|
-
downloading a script and running JavaScript, and the dialects differ per platform, so this
|
|
371
|
-
plugin does not guess. When it sees one it says so on stderr instead of quietly connecting
|
|
372
|
-
directly.
|
|
373
|
-
|
|
374
228
|
Details worth knowing:
|
|
375
229
|
|
|
376
|
-
- **
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
The
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
- **
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
model. Off - the default - those two parameters are not in the tool's surface at all, and
|
|
430
|
-
the sidecar independently refuses a non-GET with `WRITE_DISABLED`, so a hand-built frame
|
|
431
|
-
cannot write either. The two halves do not rely on each other. Turn it on only where the
|
|
432
|
-
task really is to submit data: prompt-injected page text can ask for a POST, and the SSRF
|
|
433
|
-
gate, the proxy decision and `follow_redirects="safe"` bound *where* a request goes, not
|
|
434
|
-
*what it does once there*. `headers` and `cookies` stay available either way - a credentialed
|
|
435
|
-
GET against a host you allow-listed is the normal case - but note that anything handed to
|
|
436
|
-
them lands in the model context by design. `fetchEnabled` remains the coarse kill switch.
|
|
437
|
-
- **Browser identity knobs live on the tools that can actually apply them.** `useragent` /
|
|
438
|
-
`locale` / `timezoneId` / `headless` are model-visible on the one-shot browser tools and on
|
|
439
|
-
`scrapling_session_open` - those take effect at session construction, because passing them
|
|
440
|
-
on a per-request session call is silently dropped upstream.
|
|
441
|
-
- **Credentials never reach a log or the capability frame.** The capability report echoes
|
|
442
|
-
`scheme://host:port` only, and its `source` field names which rung answered
|
|
443
|
-
(`settings` / `environment` / `system` / `none`) - that column is the first thing to look
|
|
444
|
-
at when someone reports that fetching does not work.
|
|
445
|
-
- **A malformed proxy address does not stop the plugin from loading.** A scheme outside
|
|
446
|
-
`http` / `https` / `socks4` / `socks5` / `socks5h` is logged to stderr and treated as
|
|
447
|
-
"not configured", rather than thrown out as a load failure.
|
|
448
|
-
|
|
449
|
-
## Render or static: how to choose
|
|
450
|
-
|
|
451
|
-
`scrapling_render` is much slower and heavier than `scrapling_fetch`, so start static.
|
|
452
|
-
Two criteria:
|
|
453
|
-
|
|
454
|
-
**If the result is shorter than the static fetch, go back to static.** Plenty of sites
|
|
455
|
-
ship readable text from the server (for search engines and no-JS users) and then have their
|
|
456
|
-
own script empty those containers and swap in canvas / Lottie animation - for those pages
|
|
457
|
-
rendering can only lose content, and `networkIdle`, `waitSelector`, `mainContentOnly` and
|
|
458
|
-
`headless` all fail to bring it back: in the rendered DOM those containers are simply empty.
|
|
459
|
-
That is site behaviour, not a plugin defect.
|
|
460
|
-
|
|
461
|
-
**`waitSelector` waits for an element to appear, not for content to settle.** The element
|
|
462
|
-
can be removed after it matched, so "the selector matched" does not mean that content is
|
|
463
|
-
in the result.
|
|
464
|
-
|
|
465
|
-
One thing that is not a criterion but worth knowing: axis ticks inside SVG **cannot be
|
|
466
|
-
fetched at all**. After Chromium renders, the markdown conversion emits no `<svg>` or
|
|
467
|
-
`<text>` nodes, so "the numbers on the chart" are out of reach whichever tool you use - the
|
|
468
|
-
copy on an example card is server-rendered and was already there statically, it is not a
|
|
469
|
-
rendering product. For actual values, go through `scrapling_capture_xhr` to locate the
|
|
470
|
-
JSON endpoint.
|
|
471
|
-
|
|
472
|
-
## Security notes
|
|
473
|
-
|
|
474
|
-
- **SSRF.** Scrapling itself has no SSRF protection. This plugin adds a URL policy on
|
|
475
|
-
the host side (scheme allowlist, credential rejection, length cap, rejection of an
|
|
476
|
-
authority containing a backslash or control characters, DNS resolution with a
|
|
477
|
-
whole-answer-set public-address check, and IPv4-mapped / NAT64 addresses reclassified
|
|
478
|
-
by their embedded IPv4) and enforces it again on the Python side. **What is judged is
|
|
479
|
-
what gets sent**: the gate decides on the WHATWG-normalised form and the sidecar forwards
|
|
480
|
-
that same normalised string, otherwise "judged A, connected to B" becomes a bypass in
|
|
481
|
-
its own right. The browser-side guard is registered by the plugin's own code and covers
|
|
482
|
-
navigation, subresources, XHR and WebSocket handshakes.
|
|
483
|
-
|
|
484
|
-
Known gaps, all stated in the open:
|
|
485
|
-
- **Connection pinning** (an undici-level technique) is unavailable for a non-Node
|
|
486
|
-
transport, leaving a TOCTOU window between validation and connect. Static fetches are
|
|
487
|
-
covered by curl_cffi's `follow_redirects="safe"`; browser fetches by a route handler
|
|
488
|
-
on the Python side.
|
|
489
|
-
- **NAT64 prefixes are not discovered dynamically.** dsh's built-in probes the active
|
|
490
|
-
prefix via the `ipv4only.arpa` sentinel; this plugin covers the two standardized
|
|
491
|
-
prefixes (`64:ff9b::/96`, `64:ff9b:1::/48`). Declare any operator-specific prefix via
|
|
492
|
-
the `nat64Prefixes` setting, otherwise a private IPv4 hidden inside IPv6 is judged as
|
|
493
|
-
an ordinary public IPv6. Conversely, a declared prefix applies to **every** IPv6
|
|
494
|
-
address, not only the ones inside the RFC 6052 segment.
|
|
495
|
-
- **No port allowlist** (any port allowed by default), matching dsh's own built-in
|
|
496
|
-
fetch provider.
|
|
497
|
-
- **`scrapling_crawl` re-checks addresses itself, but the start-URL gate is still the
|
|
498
|
-
first line.** The start URL goes through `guard.url_allowed` (the same implementation
|
|
499
|
-
the browser path uses, so both layers agree), the crawl session sets
|
|
500
|
-
`follow_redirects="safe"` so curl_cffi refuses to follow a jump into a private range,
|
|
501
|
-
and each page is re-checked **twice** before it enters the result set: once against
|
|
502
|
-
the guard (the final URL may still have landed somewhere private) and once against the
|
|
503
|
-
start domain - Scrapling's `allow_domains` is a string comparison that covers links
|
|
504
|
-
found in the page and not redirect targets, so an off-site jump on a public host has to
|
|
505
|
-
be caught here.
|
|
506
|
-
- **WebSocket coverage depends on the Playwright version.** The guard intercepts
|
|
507
|
-
handshakes via `route_web_socket`. Older builds lack that method, WebSocket is then
|
|
508
|
-
outside the guard, and the plugin says so in the log and in the capability report
|
|
509
|
-
rather than degrading silently.
|
|
510
|
-
- **Browser binary path and CDP endpoint are deployment-grade capabilities.** They come
|
|
511
|
-
only from deployment config and are unreachable from model input; pointing at them
|
|
512
|
-
hands over "run this file" and "attach the browser to this debugger".
|
|
513
|
-
|
|
514
|
-
The host-side policy is enforced by `SidecarClient.call`, so it covers every tool and
|
|
515
|
-
the `web_fetch` provider alike; a rejection throws `URL_BLOCKED` before the request is
|
|
516
|
-
written to the pipe. The `web_search` provider runs the same gate over the URLs it is
|
|
517
|
-
about to hand back: a hit the gate rejects never becomes a citeable source, so the model
|
|
518
|
-
is never offered an address the next fetch would refuse.
|
|
519
|
-
- **Browser engines ignore proxy environment variables.** patchright does not read
|
|
520
|
-
`HTTP_PROXY` / `HTTPS_PROXY`, so `scrapling_render` and `scrapling_capture_xhr`
|
|
521
|
-
connect **directly** even when the rest of the system is
|
|
522
|
-
routed through a proxy — a browser-bound request leaves the tunnel. curl_cffi (behind
|
|
523
|
-
`scrapling_fetch` and the crawler) *does* honour those variables, so the two halves
|
|
524
|
-
behave differently on a proxy-bound network. This is stated rather than papered over:
|
|
525
|
-
routing the browser through a proxy means handing the plugin a deployment-grade
|
|
526
|
-
capability, and shipping that without a way to check it against a live proxy would be
|
|
527
|
-
worse than saying so. `allowSyntheticDns` above only fixes the *gate*; it does not
|
|
528
|
-
change where traffic goes.
|
|
529
|
-
- **There are quotas; the resident resources are not unbounded.** At most 8 concurrent
|
|
530
|
-
sessions (of which at most 3 may be browser sessions — the `stealth` session type, each a
|
|
531
|
-
real Chromium process), at
|
|
532
|
-
most 2 crawls in flight, per-page bodies clipped at `maxContentChars`, 8 MB per protocol
|
|
533
|
-
frame, and 16 frames of pending queue. Hitting a ceiling yields a specific error code
|
|
534
|
-
(`SESSION_LIMIT` / `CRAWL_BUSY` / `BAD_FRAME`) the model can back off from, rather than
|
|
535
|
-
exhausting the machine.
|
|
536
|
-
- **No code execution from the model.** `page_action`, `page_setup`, `selector_config`,
|
|
537
|
-
`proxy`, `executablePath` and `cdpUrl` are never exposed in any tool schema. The
|
|
538
|
-
browser-side network guard is
|
|
539
|
-
installed by plugin code, never by model input.
|
|
540
|
-
- **Prompt-injection scrubbing** runs unconditionally on returned content; there is no
|
|
541
|
-
model-facing switch to turn it off.
|
|
542
|
-
|
|
543
|
-
## Development
|
|
230
|
+
- **The resolved proxy is handed to the browser engine explicitly.** Chromium does not read `HTTP_PROXY` / `ALL_PROXY`, so a proxy that is only exported in a shell would cover static fetches but not the browser — this package closes that gap by passing the resolved proxy on every browser fetch. A **browser session** still picks its proxy once, at `scrapling_session_open`: switching it means a new browser context, which throws away the session's cookies and login state — precisely the reason a session exists. Static sessions decide per request.
|
|
231
|
+
- **PAC is the one shape that needs a hand-filled `proxyUrl`.** Evaluating a PAC script means downloading it and running JavaScript, and the dialects differ per platform, so this package does not guess; static fetching says so on stderr, and the browser follows PAC natively through its own system settings.
|
|
232
|
+
- **A proxy and synthetic DNS are two different problems.** A fake-IP proxy resolves **every** domain into `198.18.0.0/15` (TUN clients often `100.64.0.0/10`); neither is public unicast, so the gate would reject every URL — turning a proxy on would stop the plugin from working. The gate detects that class of resolver on its own (three control names unrelated to any target, all landing in one non-public pool while staying distinct) and then relaxes to the **whole** of the known pools. The control names only trigger the verdict, never size the pool — three hashed answers carry no size information. Private, loopback and link-local ranges are in neither pool, so intranet and metadata addresses stay blocked on a proxied machine. `syntheticDnsRanges` is the manual fallback for a self-built pool outside the two ranges; when detection does not fire, the gate **stays strict**.
|
|
233
|
+
- **Through a proxy, a host name this machine cannot resolve is no longer rejected.** The proxy resolves it, and on a network with DNS filtered by region those are exactly the sites that need a proxy. IP literals, private answers the local resolver *can* produce, and single-label host names (`intranet`, `router`) stay rejected.
|
|
234
|
+
- **WebRTC leaks are closed whenever a proxy is in play.** Chromium's WebRTC can send UDP around an HTTP/SOCKS proxy, and one STUN call in a page is enough to learn the visitor's real exit address; `blockWebrtc` is forced on with a proxy, no model input involved.
|
|
235
|
+
- **Credentials never reach a log or the capability frame.** The report echoes `scheme://host:port` only, with a `source` field (`settings` / `environment` / `system` / `none`) — the first column to read when someone reports that fetching does not work. A malformed proxy address is logged to stderr and treated as "not configured" rather than failing the load.
|
|
236
|
+
|
|
237
|
+
## <img src="https://api.iconify.design/lucide/shield-alert.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> Security
|
|
238
|
+
|
|
239
|
+
- **SSRF.** Scrapling itself has no SSRF protection. This package adds a URL policy on the host side — scheme allowlist, rejection of URLs with embedded credentials, length cap, rejection of an authority containing a backslash or control characters, DNS resolution with a whole-answer-set public-address check, IPv4-mapped and NAT64 addresses reclassified by their embedded IPv4 — and enforces it again on the Python side. **What is judged is what gets sent**: the gate decides on the WHATWG-normalised form and the sidecar forwards that same string, otherwise "judged A, connected to B" would be a bypass in its own right. The host-side policy is enforced in one place (`SidecarClient.call`), so it covers every tool and the `web_fetch` provider alike, with a rejection throwing `URL_BLOCKED` before the request reaches the pipe; the `web_search` provider runs the same gate over the URLs it is about to return, so a hit the gate rejects never becomes a citeable source. The browser-side guard covers navigation, subresources, XHR and WebSocket handshakes.
|
|
240
|
+
- Known gaps, stated in the open:
|
|
241
|
+
- **Connection pinning** (an undici-level technique) is unavailable for a non-Node transport, leaving a TOCTOU window between validation and connect. Static fetches are covered by curl_cffi's `follow_redirects="safe"`; browser fetches by a route handler on the Python side.
|
|
242
|
+
- **NAT64 prefixes are not discovered dynamically.** The two standardized prefixes are covered; operator-specific ones must be declared via `nat64Prefixes`, otherwise a private IPv4 hidden inside IPv6 is judged as an ordinary public IPv6.
|
|
243
|
+
- **No port allowlist** (any port allowed by default), matching dsh's own built-in fetch provider.
|
|
244
|
+
- **The crawl re-checks every page twice** before it enters the result set — once against the guard (the final URL may still have landed somewhere private) and once against the start domain, because Scrapling's `allow_domains` is a string comparison over links found in the page, not redirect targets. The crawl session uses `follow_redirects="safe"` so curl_cffi refuses a jump into a private range.
|
|
245
|
+
- **WebSocket coverage depends on the Playwright version.** The guard intercepts handshakes via `route_web_socket`; older builds lack that method, WebSocket is then outside the guard, and the plugin says so in the log and the capability report rather than degrading silently.
|
|
246
|
+
- **No code execution from model input.** `page_action`, `page_setup`, `selector_config`, `proxy`, `executablePath` and `cdpUrl` never appear in any tool schema, and the browser-side network guard is installed by plugin code. The strong browser capabilities and `allowWriteMethods` come only from deployment config.
|
|
247
|
+
- **Write verbs are off by default.** With `allowWriteMethods` off, `method` and `body` are absent from `scrapling_fetch`'s parameter surface, and the sidecar independently refuses a non-GET with `WRITE_DISABLED` — two halves that do not rely on each other. The gate, the proxy decision and `follow_redirects="safe"` bound **where** a request goes, not **what it does once there**; prompt-injected page text can ask for a POST, so turn it on only where the task really is to submit data. `headers` and `cookies` stay available either way — anything handed to them lands in the model context by design.
|
|
248
|
+
- **Prompt-injection scrubbing runs unconditionally** on all three extraction paths; there is no model-facing switch to turn it off.
|
|
249
|
+
|
|
250
|
+
## <img src="https://api.iconify.design/lucide/lock.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> Data and privacy
|
|
251
|
+
|
|
252
|
+
| Aspect | Content |
|
|
253
|
+
| --- | --- |
|
|
254
|
+
| On disk | The sidecar working directory (`dataDir`, default `~/.dsh-scrapling`) holds Scrapling's `adaptive` fingerprint database; login-state files are written under `sessionStateDir` when it is configured. Settings values live in the host settings document. Nothing else is written |
|
|
255
|
+
| Network | Fetches go to the URLs the model supplies, through the configured proxy if any. Search queries go to the deployment-level `searchEndpoint`. `scrapling_answer` sends the fetched page text and the question through the host `llm` service — that content leaves the machine when the routed model is remote |
|
|
256
|
+
| Logs | The chosen interpreter, the probed capabilities, and the proxy summary (`scheme://host:port` plus which rung answered — never credentials) |
|
|
257
|
+
| In memory | Sessions, cookies and recorded network history live in the sidecar process and disappear with it |
|
|
258
|
+
| Telemetry | None |
|
|
259
|
+
|
|
260
|
+
## <img src="https://api.iconify.design/lucide/triangle-alert.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> Known boundaries
|
|
261
|
+
|
|
262
|
+
Registered honestly, one entry per class.
|
|
263
|
+
|
|
264
|
+
- **Rendering can only lose content on pages that ship readable text and then swap it out.** Sites that serve text for search engines and no-JS users, then empty those containers into canvas / Lottie animation, come back emptier after rendering — see [Render or static](#render-or-static).
|
|
265
|
+
- **Axis ticks inside SVG are unreachable in every tool**: the Markdown conversion emits no `<svg>` / `<text>` nodes. For chart values, locate the JSON endpoint with `scrapling_capture_xhr`.
|
|
266
|
+
- **A browser session's proxy is fixed at `session_open`**, and `proxyBypass` does not apply per URL inside it (a context switch would discard the cookies and login state that are the point of a session). Static sessions decide per request.
|
|
267
|
+
- **`headers` and `retries` on `scrapling_session_fetch` belong to static sessions.** Upstream silently drops both for browser sessions, so this package refuses them with `BAD_ARGS` naming the knob to use instead — a silent no-op is the failure mode it exists to eliminate.
|
|
268
|
+
- **Browser identity knobs only live on the tools that can apply them.** `useragent` / `locale` / `timezoneId` / `headless` are model-visible on the one-shot browser tools and on `scrapling_session_open` — they take effect at session construction, and passing them per request is silently dropped upstream.
|
|
269
|
+
- **Network history is session-level.** Recording is a construction-time setting (`recordRequests` deployment default, or `recordNetwork` per `scrapling_session_open`); a session that is not recording answers an error, not an empty list.
|
|
270
|
+
|
|
271
|
+
## <img src="https://api.iconify.design/lucide/circle-help.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> FAQ
|
|
272
|
+
|
|
273
|
+
| Question | Answer |
|
|
274
|
+
| --- | --- |
|
|
275
|
+
| The model says the render / capture_xhr tools do not exist | No browser engine on this machine — the plugin registers only what works. Run `python -m patchright install chromium` and restart. If **every** tool is missing, the sidecar did not start: the startup log names the chosen interpreter, and a missing Scrapling carries the pip line to copy |
|
|
276
|
+
| After enabling a proxy, every fetch is blocked | A fake-IP proxy resolves every domain into a non-public range; the gate auto-detects that class and relaxes to the known pools. A self-built pool outside them goes into `syntheticDnsRanges`. Private and loopback addresses stay blocked on purpose |
|
|
277
|
+
| `web_fetch` reports `WEB_PROVIDER_CONFIGURED_UNAVAILABLE` / `_MISSING` | The deployment line points at this plugin: either the sidecar is down (interpreter or Scrapling — see the startup log), or the plugin was removed and the `fetchProvider` / `searchProvider` line is still there. Remove the line too |
|
|
278
|
+
| The model cannot POST a form | `allowWriteMethods` is off by default and deployment-only — it decides whether the model may change state on a remote host |
|
|
279
|
+
| `web_search` returns nothing | Scrapling is not a search engine. Point the deployment-level `searchEndpoint` at a SearXNG-compatible JSON backend |
|
|
280
|
+
| The numbers on a chart are missing | SVG tick labels do not survive the Markdown conversion in any tool. Use `scrapling_capture_xhr` to find the JSON endpoint behind the chart |
|
|
281
|
+
|
|
282
|
+
## <img src="https://api.iconify.design/lucide/wrench.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> Development
|
|
544
283
|
|
|
545
284
|
```sh
|
|
546
|
-
pnpm install
|
|
547
|
-
pnpm run check
|
|
548
|
-
pnpm run
|
|
549
|
-
pnpm run test:py # end-to-end check of the Python sidecar (needs _env/.venv)
|
|
285
|
+
pnpm install
|
|
286
|
+
pnpm run check # typecheck → lint → client build → host build → tests → format, then the Python chain
|
|
287
|
+
pnpm run test:py # end-to-end check of the Python sidecar
|
|
550
288
|
```
|
|
551
289
|
|
|
552
|
-
**The Python half is gated
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
290
|
+
- **The Python half is gated like the TypeScript half.** `check` ends with `check:py`: an interpreter report, a face count (the shipped `.py` files and the test directory must both be there — a missing test directory makes "clean" and "untested" indistinguishable), ruff check, ruff format, mypy, the sidecar end-to-end, bandit (medium and above), and a coverage floor measured **only over the modules that ship**. Dev tools: `pip install -r py/requirements-dev.txt` into the interpreter `test:py` uses.
|
|
291
|
+
- **The Python 3.14 floor is one fact in four places:** both READMEs, the ruff and mypy targets, and a runtime gate in `py/bridge.py` that exits before any Scrapling import with a clean stdout — stdout is protocol frames, so an old interpreter shows the exit code and a stderr line instead of garbage.
|
|
292
|
+
- **mypy runs non-strict on purpose.** Playwright's `page` / `route` / `websocket` objects have no shape until runtime, and a strict profile would buy a pile of `ignore` comments that exist only to silence it.
|
|
293
|
+
- Sources are TypeScript. `host.js` and `client.js` are **build artifacts** and deliberately `.js`: Node refuses to strip types for packages inside `node_modules`, which is exactly where dsh loads the plugin from. The artifact is ESM-only; `require()` will not get you the plugin, and that is deliberate.
|
|
294
|
+
- Gates that pin the published shape: `test/publish-manifest.test.ts` (entry targets covered by `files`, no source file as an entry point, `dsh-*` pins exact and uniform, no host package body inlined, no dates or bad bytes in comments or documents) and `test/readme-parity.test.ts` (the two READMEs name every tool and every settings-card knob, and their section structures match).
|
|
295
|
+
- Publishing runs through [`.github/workflows/publish.yml`](./.github/workflows/publish.yml) (manual, OIDC trusted publishing plus `--provenance`).
|
|
557
296
|
|
|
558
|
-
|
|
559
|
-
pip install -r py/requirements-dev.txt
|
|
560
|
-
```
|
|
561
|
-
|
|
562
|
-
Two more commands measure rather than gate:
|
|
297
|
+
## <img src="https://api.iconify.design/lucide/scale.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> License
|
|
563
298
|
|
|
564
|
-
|
|
565
|
-
pnpm run typecheck:py # mypy over py/ (currently clean; why it stays advisory is below)
|
|
566
|
-
pnpm run cov:py # coverage for the four shipped modules + the test script
|
|
567
|
-
```
|
|
299
|
+
MIT. Source at [github.com/JayYuen666/dsh-scrapling](https://github.com/JayYuen666/dsh-scrapling). Issues go to that repository's tracker.
|
|
568
300
|
|
|
569
|
-
|
|
570
|
-
That is not decoration: mypy's findings depend on it. From an interpreter without
|
|
571
|
-
Scrapling every Scrapling type degrades to `Any` and the check reports nothing at all.
|
|
572
|
-
|
|
573
|
-
`mypy` stays advisory because this side is duck-typed on purpose — Playwright's `page`,
|
|
574
|
-
`route` and `websocket` have no shape until runtime — and a strict profile would buy a
|
|
575
|
-
pile of `ignore` comments that exist only to silence it. `cov:py` is advisory because its
|
|
576
|
-
honest number needs the subprocess wired in: `bridge.py` and the `adapters` methods live
|
|
577
|
-
in the sidecar child, so `test_bridge.py` spawns that child under `coverage run` when
|
|
578
|
-
`DSH_PY_COVERAGE=1`. Without it the report reads `adapters.py` 20% while none of its fetch
|
|
579
|
-
paths have been counted at all — a number that measures nothing. Current shape:
|
|
580
|
-
`adapters` 65%, `bridge` 37%, `crawl` 89%, `guard` 85%.
|
|
581
|
-
|
|
582
|
-
Sources are all TypeScript. `host.js` and `client.js` are **build artifacts** and are
|
|
583
|
-
deliberately `.js`: Node refuses to strip types for packages inside `node_modules`,
|
|
584
|
-
which is exactly where dsh loads the plugin from.
|
|
585
|
-
|
|
586
|
-
The artifact is **ESM-only**: `require()` will not get you the plugin. That is deliberate
|
|
587
|
-
(the host loads it by package name), not a defect.
|
|
588
|
-
|
|
589
|
-
At build time every package declared in `dependencies`, `peerDependencies` **or**
|
|
590
|
-
`devDependencies` is externalised. The ones the host provides at runtime (cordis,
|
|
591
|
-
dsh-tools, dsh-subprocess, dsh-jobs) must not be inlined: the bundle would otherwise
|
|
592
|
-
carry its own private copy, splitting module-level state, and for packages that resolve
|
|
593
|
-
their own `package.json` relative to `import.meta.url` it would fail to load outright with
|
|
594
|
-
`MODULE_NOT_FOUND`. `test/publish-manifest.test.ts` imports the built artifact and asserts
|
|
595
|
-
that no host package body is inlined, so both halves stay pinned.
|
|
596
|
-
|
|
597
|
-
Publishing runs through [`.github/workflows/publish.yml`](./.github/workflows/publish.yml)
|
|
598
|
-
(manual, OIDC trusted publishing plus `--provenance`).
|
|
599
|
-
|
|
600
|
-
## License
|
|
601
|
-
|
|
602
|
-
MIT — see [`LICENSE`](./LICENSE). Where this package stops and third-party code begins:
|
|
603
|
-
[`THIRD_PARTY_NOTICES.md`](./THIRD_PARTY_NOTICES.md).
|
|
301
|
+
This package ships no third-party source code — Scrapling and the browser engines are runtime dependencies, and the only third-party content in the package is the icon (Tabler Icons). [`THIRD_PARTY_NOTICES.md`](./THIRD_PARTY_NOTICES.md) records that boundary.
|