@capyclaw/scrapling 1.0.2 → 1.1.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/README.md CHANGED
@@ -1,264 +1,177 @@
1
1
  # dsh-scrapling
2
2
 
3
- Scrapling 网页抓取插件 - 为 DeepSeek Harness 提供强大的网页抓取能力
3
+ Scrapling 网页抓取插件 —— 为 DeepSeek Harness 提供网页数据爬取能力 + **可视化爬虫工作台**。
4
4
 
5
5
  ## 功能特性
6
6
 
7
- ### 🚀 核心功能
8
- - **快速 HTTP 请求** - 高性能的静态页面抓取
9
- - **隐身浏览器** - 真实浏览器渲染,绕过反爬虫检测
10
- - **Cloudflare 绕过** - 自动处理 Cloudflare Turnstile/Interstitial
11
- - **JavaScript 渲染** - 完整的 JS 页面支持
12
- - **CSS/XPath 选择器** - 强大的元素选择和提取
13
- - **并发爬虫** - 高效的多线程爬取
14
- - **代理轮换** - 自动代理管理和轮换
15
- - **自适应解析** - 智能元素追踪,适应页面变化
16
- - **多格式导出** - JSON、CSV、XML 等格式
7
+ ### ✅ 已实现(纯 Node,零外部依赖)
17
8
 
18
- ## 安装
9
+ - **HTTP 抓取** —— 直连目标网址,跟随重定向,超时可控,错误翻译成人话(含「下一步」提示)
10
+ - **CSS 选择器提取** —— 自研容错 HTML 解析器 + 选择器引擎(Scrapy/parsel 语义)
11
+ - `::text` / `::attr(name)` 伪元素
12
+ - 类型/类/ID/属性选择器(`=` `^=` `$=` `*=` `~=` `|=`)
13
+ - 后代 / 子代 `>` / 相邻 `+` 组合器
14
+ - `:first-child` / `:last-child` / `:nth-child(k)`
15
+ - 逗号分组按文档序合并去重(XPath union 语义)
16
+ - 支持中文类名/属性值
17
+ - **爬虫工作台**(`http://127.0.0.1:39640/`)—— 浏览器打开即用:
18
+ - 三步引导:选目标 → 观察流程 → 取数据
19
+ - 爬取流程逐步回放(每步真实耗时:解析 URL → 发请求 → 收响应 → 读内容 → 建文档树 → 提取 → 完成)
20
+ - 选择器试玩(随时改随时提取,不重新请求)
21
+ - 结果表格 / JSON 双视图,复制 JSON、导出 CSV(Excel 可直接打开)/ JSON
22
+ - 最近 20 条历史,点击回看
23
+ - 三个内置离线演示页(名言 / 商品 / 新闻),无需外网即可完整体验
24
+ - **服务契约** —— `/healthz`、`/metrics`(Prometheus)、只监听 `127.0.0.1`
19
25
 
20
- ### 前提条件
26
+ ### 🔒 未实现(诚实声明,不会伪造结果)
21
27
 
22
- 需要安装 Python 和 Scrapling 包:
28
+ - **浏览器渲染 / 隐身模式 / Cloudflare 绕过 / JS 渲染** —— 依赖外部 Python `scrapling` 运行时,调用返回结构化 `NOT_IMPLEMENTED`,工作台界面上已锁定
29
+ - **XPath** —— 同上
23
30
 
24
- ```bash
25
- # 安装 Scrapling 及所有依赖
26
- pip install "scrapling[all]>=0.5"
27
-
28
- # 安装浏览器引擎(用于 JavaScript 渲染)
29
- scrapling install --force
30
- ```
31
+ ## 快速开始
31
32
 
32
- ### 插件安装
33
+ ```bash
34
+ # 方式一:独立启动工作台(推荐,浏览器打开即用)
35
+ cd extensions/official/capyclaw-scrapling
36
+ node server/server.mjs # 默认 http://127.0.0.1:39640/
37
+ # 或指定端口
38
+ node server/server.mjs --port 39641
33
39
 
34
- 本插件已集成在 DeepSeek Harness 的官方扩展中,通过 DSH 的插件系统自动加载。
40
+ # 方式二:作为 DSH 插件加载(自动注册服务并拉起工作台)
41
+ # cordis.patch.yml 已配置 port: 39640
35
42
 
36
- ## 使用方法
43
+ # 单元测试(32 项)
44
+ npm test
45
+ ```
37
46
 
38
- ### API 调用
47
+ ## API
39
48
 
40
- 插件通过 Cordis 依赖注入系统提供 `scrapling` 服务:
49
+ ### 服务 API(`ctx.scrapling`)
41
50
 
42
51
  ```javascript
43
- // 在其他插件中使用
44
52
  export const inject = ['scrapling']
45
53
 
46
54
  export async function apply(ctx) {
47
- // HTTP 抓取
48
- const result = await ctx.scrapling.fetch('https://example.com')
49
- console.log(result.html)
50
-
51
- // 浏览器模式抓取
52
- const browserResult = await ctx.scrapling.fetchWithBrowser('https://example.com', {
53
- waitFor: '.content',
54
- timeout: 10000
55
+ // 1. HTTP 抓取
56
+ const page = await ctx.scrapling.fetch('https://quotes.toscrape.com/')
57
+ console.log(page.status, page.html.length)
58
+
59
+ // 2. 解析 + 选择器提取(Scrapy 语义)
60
+ const doc = ctx.scrapling.parse(page.html)
61
+ doc.css('.quote .text::text') // → ['“Quote one.”', '“Quote two.”', …]
62
+ doc.css('a::attr(href)') // → ['/tag/change/1', …]
63
+ const quotes = doc.css('.quote') // → 元素包装(.attrib / .text / .css())
64
+
65
+ // 3. 带步骤计时的爬取流水线(工作台数据源)
66
+ const record = await ctx.scrapling.crawler.crawl({
67
+ url: 'https://example.com/',
68
+ selectors: [{ key: '标题', selector: 'h1::text' }],
55
69
  })
56
-
57
- // 解析 HTML
58
- const doc = ctx.scrapling.parse(result.html)
59
- const titles = doc.css('h1::text')
70
+ console.log(record.steps) // 每步 { id, label, status, detail, ms }
71
+ console.log(record.extracts) // { 标题: { selector, count, values } }
60
72
  }
61
73
  ```
62
74
 
63
- ### Python 集成
64
-
65
- 插件内部通过以下方式调用 Scrapling:
66
-
67
- #### 基础抓取
68
- ```python
69
- from scrapling.fetchers import Fetcher
70
-
71
- page = Fetcher.get('https://quotes.toscrape.com/')
72
- quotes = page.css('.quote .text::text').getall()
73
- ```
74
-
75
- #### 浏览器模式
76
- ```python
77
- from scrapling.fetchers import StealthyFetcher
78
-
79
- page = StealthyFetcher.get('https://example.com',
80
- wait_selector='.content',
81
- wait_timeout=10)
82
- title = page.css('h1::text').get()
83
- ```
84
-
85
- #### Spider 爬虫
86
- ```python
87
- from scrapling.spiders import Spider, Response
88
-
89
- class QuotesSpider(Spider):
90
- name = "quotes"
91
- start_urls = ["https://quotes.toscrape.com/"]
92
-
93
- async def parse(self, response: Response):
94
- for quote in response.css('.quote'):
95
- yield {
96
- "text": quote.css('.text::text').get(),
97
- "author": quote.css('.author::text').get(),
98
- }
99
- ```
100
-
101
- ## 配置选项
102
-
103
- 在 `cordis.patch.yml` 中可以配置:
104
-
105
- ```yaml
106
- - insert:
107
- - id: scrapling-host
108
- name: dsh-scrapling
109
- config:
110
- enabled: true
111
- defaultTimeout: 30000
112
- maxConcurrentRequests: 10
113
- ```
114
-
115
- ## 架构设计
116
-
117
- ### 宿主半(lib/host.mjs)
118
- - 通过 Cordis 插件系统注册服务
119
- - 提供 Scrapling API 的 JavaScript 封装
120
- - 管理 Python 进程或 HTTP API 调用
121
-
122
- ### 浏览器半(client/client.js)
123
- - 提供前端 UI 集成
124
- - 注册命令和快捷键
125
- - 显示抓取状态和结果
126
-
127
- ## API 参考
128
-
129
- ### ctx.scrapling.fetch(url, options)
130
-
131
- 使用 HTTP 模式抓取页面。
132
-
133
- **参数:**
134
- - `url` (string) - 目标 URL
135
- - `options` (object) - 可选配置
136
- - `headers` - 自定义请求头
137
- - `proxy` - 代理地址
138
- - `timeout` - 超时时间(毫秒)
139
-
140
- **返回:** Promise<{ url, html, status }>
141
-
142
- ### ctx.scrapling.fetchWithBrowser(url, options)
75
+ **诚实边界:** `fetchWithBrowser()` 与 XPath 抛 `NOT_IMPLEMENTED`。
143
76
 
144
- 使用浏览器模式抓取页面。
77
+ ### HTTP API(工作台服务)
145
78
 
146
- **参数:**
147
- - `url` (string) - 目标 URL
148
- - `options` (object) - 可选配置
149
- - `waitFor` - 等待的选择器
150
- - `timeout` - 超时时间(毫秒)
151
- - `screenshot` - 是否截图
79
+ | 接口 | 方法 | 说明 |
80
+ |---|---|---|
81
+ | `/healthz` | GET | `{ ok, name, version, contractVersion, uptimeSec, port, pid, capabilities }` |
82
+ | `/metrics` | GET | Prometheus 文本(`scrapling_up` / `scrapling_crawls_total` 等) |
83
+ | `/api/crawl` | POST | `{ url, timeoutMs?, userAgent?, selectors?: [{key, selector}] }` → 步骤流水线 + 提取结果 |
84
+ | `/api/extract` | POST | `{ crawlId, selectors }` 基于历史记录二次提取(免重新请求) |
85
+ | `/api/crawls` | GET | 最近 20 条爬取摘要 |
86
+ | `/api/crawls/:id` | GET | 单条记录详情(含 htmlPreview) |
87
+ | `/demo/*.html` | GET | 内置离线演示页(quotes / products / news) |
152
88
 
153
- **返回:** Promise<{ url, html, screenshot? }>
89
+ ## 配置
154
90
 
155
- ### ctx.scrapling.parse(html)
91
+ `cordis.patch.yml`(优先级:cordis config → 环境变量 → 默认值):
156
92
 
157
- 解析 HTML 内容。
93
+ | 配置 | 环境变量 | 默认 | 说明 |
94
+ |---|---|---|---|
95
+ | `enabled` | `DSH_SCRAPLING_ENABLED` | `true` | 是否注册服务与工作台 |
96
+ | `port` | `DSH_SCRAPLING_PORT` | `39640` | 工作台端口 |
97
+ | `host` | `DSH_SCRAPLING_HOST` | `127.0.0.1` | 监听地址 |
98
+ | `timeoutMs` | `DSH_SCRAPLING_TIMEOUT_MS` | `20000` | 默认请求超时 |
99
+ | `workbench` | `DSH_SCRAPLING_WORKBENCH` | `true` | 是否拉起工作台界面 |
158
100
 
159
- **参数:**
160
- - `html` (string) - HTML 字符串
161
-
162
- **返回:** ParsedDocument - 包含 css() 和 xpath() 方法的文档对象
163
-
164
- ## 开发
165
-
166
- ### 目录结构
101
+ ## 架构
167
102
 
168
103
  ```
169
- dsh-scrapling/
104
+ capyclaw-scrapling/
170
105
  ├── lib/
171
- │ ├── host.mjs # Cordis 插件入口
172
- │ └── index.mjs # API 导出
106
+ │ ├── host.mjs # Cordis 入口:注册服务 + 拉起工作台 + boot 全局注入
107
+ │ ├── index.mjs # API 导出
108
+ │ ├── html-parser.mjs # 容错 HTML 解析器(单遍、隐式闭合、实体解码)
109
+ │ ├── selectors.mjs # CSS 选择器引擎(parsel 语义)
110
+ │ └── crawler.mjs # 爬取流水线(步骤计时 + 历史记录)
111
+ ├── server/
112
+ │ └── server.mjs # 工作台 HTTP 服务(独立入口 / 被宿主拉起)
113
+ ├── ui/
114
+ │ ├── index.html # 工作台界面(无框架无构建)
115
+ │ ├── app.js
116
+ │ └── style.css
117
+ ├── demo/ # 内置离线演示页(爬取目标 + 选择器教学)
173
118
  ├── client/
174
- │ └── client.js # 浏览器端代码
175
- ├── test/
176
- │ └── plugin.test.mjs # 测试文件
177
- ├── cordis.patch.yml # Bundle 配置
178
- ├── package.json # 包定义
179
- └── README.md # 本文件
180
- ```
181
-
182
- ### 运行测试
183
-
184
- ```bash
185
- npm test
186
- ```
187
-
188
- ## 示例
189
-
190
- ### 示例 1: 抓取引言网站
191
-
192
- ```javascript
193
- const quotes = await ctx.scrapling.fetch('https://quotes.toscrape.com/')
194
- const doc = ctx.scrapling.parse(quotes.html)
195
- const allQuotes = doc.css('.quote .text::text')
196
- console.log('找到', allQuotes.length, '条引言')
197
- ```
198
-
199
- ### 示例 2: 处理动态页面
200
-
201
- ```javascript
202
- const page = await ctx.scrapling.fetchWithBrowser('https://example.com', {
203
- waitFor: '.dynamic-content',
204
- timeout: 10000
205
- })
206
- const doc = ctx.scrapling.parse(page.html)
207
- const content = doc.css('.dynamic-content::text')
208
- ```
209
-
210
- ### 示例 3: 使用代理
211
-
212
- ```javascript
213
- const result = await ctx.scrapling.fetch('https://example.com', {
214
- proxy: 'http://proxy.example.com:8080'
215
- })
119
+ │ └── client.js # 浏览器半:把工作台挂进 DSH 右侧边栏(iframe)
120
+ ├── test/ # 32 项单测(node --test)
121
+ └── cordis.patch.yml # bundle 配置
216
122
  ```
217
123
 
218
- ## 故障排除
219
-
220
- ### Scrapling 未安装
124
+ **与 DSH web 客户端的桥**:宿主半通过 `webserver/index-inject` 注入 `__DSH_SCRAPLING__`(协议与 launchpad / port-sidebar 相同),浏览器半据此把工作台挂成右侧边栏面板。
221
125
 
222
- **错误**: `ModuleNotFoundError: No module named 'scrapling'`
126
+ ## 测试与验证
223
127
 
224
- **解决方案**:
225
128
  ```bash
226
- pip install "scrapling[all]>=0.5"
227
- ```
129
+ # 单元测试(52 项:解析器 / 选择器 / API / 宿主装配 / 真实世界边界)
130
+ cd extensions/official/capyclaw-scrapling && npm test
228
131
 
229
- ### 浏览器未安装
132
+ # 真实互联网实测(多站点多结构:quotes/books/baidu/gitee/httpbin)
133
+ node test/internet-campaign.mjs
230
134
 
231
- **错误**: Browser 相关错误
135
+ # 六层 e2e(scrapling 在 L3 有 7 项专属冒烟:healthz/metrics/页面/离线自爬/二次提取/诚实拒绝/单测)
136
+ node scripts/e2e-all.mjs --layer l3
232
137
 
233
- **解决方案**:
234
- ```bash
235
- scrapling install --force
138
+ # 插件规范校验
139
+ node tools/capyclaw-plugin-validator/bin/cli.mjs extensions/official/capyclaw-scrapling
236
140
  ```
237
141
 
238
- ### 权限问题
142
+ ## 故障排除
239
143
 
240
- 确保 DSH 进程有权限执行 Python 和访问网络。
144
+ | 症状 | 处理 |
145
+ |---|---|
146
+ | 打不开 39640 | `node server/server.mjs` 看启动日志;端口被占时用 `--port` 换一个 |
147
+ | 爬取报「无法连接到目标网址」 | 先在浏览器里确认目标网址能打开;内网地址确认服务已启动 |
148
+ | 提取 0 条数据 | 展开页面上的「原始 HTML」对照选择器写法;从演示目标开始学 |
149
+ | 想要浏览器渲染 / XPath | 当前版本未实现,需要外部 Python scrapling 运行时 |
241
150
 
242
151
  ## 相关链接
243
152
 
244
- - **Scrapling 官方文档**: https://scrapling.readthedocs.io
245
- - **Scrapling GitHub**: https://github.com/D4Vinci/Scrapling
246
- - **MCP Server 文档**: https://scrapling.readthedocs.io/en/latest/ai/mcp-server.html
247
- - **DSH 插件开发**: ../../docs/guides/plugin-development.md
153
+ - **Scrapling 官方文档**: https://scrapling.readthedocs.io
154
+ - **Scrapling GitHub**: https://github.com/D4Vinci/Scrapling
155
+ - **DSH 插件开发**: ../../docs/guides/plugin-development.md
248
156
 
249
157
  ## 许可证
250
158
 
251
159
  MIT License
252
160
 
253
- ## 作者
254
-
255
- - **Scrapling**: D4Vinci
256
- - **DSH 集成**: DeepSeek Harness Team
257
-
258
161
  ## 版本历史
259
162
 
260
- ### 1.0.0 (2026-11-04)
261
- - 初始版本
262
- - 基础 HTTP 抓取功能
263
- - 浏览器模式支持
264
- - HTML 解析功能
163
+ ### 1.1.0 (2026-11-05)
164
+ - 🆕 可视化爬虫工作台(`http://127.0.0.1:39640/`):流程回放、选择器试玩、JSON/CSV 导出、历史回看、三个内置离线演示页
165
+ - 🆕 `parse()` 真实实现:自研容错 HTML 解析器 + CSS 选择器引擎(`::text` / `::attr` / 组合器 / 伪类 / 中文标识符)
166
+ - 🆕 爬取流水线 `crawler.crawl()`:步骤计时、结构化错误(含「下一步」提示)、20 条历史
167
+ - 🆕 服务契约 `/healthz` + `/metrics`,浏览器半挂 DSH 右侧边栏
168
+ - 🔧 E2E 加固(大规模端到端测试发现并修复):
169
+ - **多编码解码**:响应头 charset → BOM → meta 嗅探三级解码,GBK/GB2312/GB18030/UTF-16 中文老站点不再乱码
170
+ - **深度上限 512**(浏览器同款):5 万层嵌套不再栈溢出
171
+ - **结构伪类 O(1) 化**:兄弟位置索引缓存,2MB/5 万元素页面提取从 49.5s 降到 0.42s
172
+ - **大结果渲染上限**:表格只画前 500 行,导出仍含全部数据
173
+ - ✅ 52 项单测(含 20 项真实世界边界场景)+ e2e L3 七项专属冒烟 + 真实互联网多站点实测
174
+ - 诚实边界不变:浏览器渲染 / XPath 未实现并如实标注
175
+
176
+ ### 1.0.2 (2026-11-04)
177
+ - 初始版本(仅 HTTP fetch)
package/client/client.js CHANGED
@@ -1,7 +1,9 @@
1
1
  /**
2
2
  * dsh-scrapling 浏览器半
3
- *
4
- * 提供 Scrapling 功能的前端界面集成
3
+ *
4
+ * 宿主半会把工作台地址注入为 boot 全局 __DSH_SCRAPLING__(协议与
5
+ * launchpad / port-sidebar 相同)。这里把工作台挂进右侧边栏 iframe;
6
+ * 在没有 DSH web 客户端(直接用浏览器打开工作台)时静默跳过,不报错。
5
7
  */
6
8
  window.__ModuleLoader__.load({ id: '@capyclaw/scrapling', factory: (require) => {
7
9
  var module = { exports: {} }; var exports = module.exports;
@@ -10,11 +12,28 @@ window.__ModuleLoader__.load({ id: '@capyclaw/scrapling', factory: (require) =>
10
12
  name: 'dsh-scrapling',
11
13
  inject: ['slots'],
12
14
  apply: function (ctx) {
13
- console.log('[dsh-scrapling] 客户端已加载')
14
-
15
- // 在这里可以注册 UI 组件、命令等
16
-
17
- // 清理函数
15
+ var boot = globalThis.__DSH_SCRAPLING__
16
+ if (!boot || !boot.url || !ctx.slots) {
17
+ console.log('[dsh-scrapling] 客户端已加载(工作台地址未注入,跳过面板注册;可直接访问 http://127.0.0.1:39640/)')
18
+ return
19
+ }
20
+
21
+ try {
22
+ var React = require('react')
23
+ var PANEL_ID = 'scrapling-workbench'
24
+ var panel = React.createElement('iframe', {
25
+ src: boot.url,
26
+ title: 'DSH 爬虫工作台',
27
+ style: { width: '100%', height: '100%', border: 'none' },
28
+ })
29
+ ctx.slots.inject('sidebar.right.pane.tab', function () {
30
+ return ctx.slots.register({ name: 'sidebar.right.pane.tab.scrapling', key: PANEL_ID }, panel)
31
+ })
32
+ console.log('[dsh-scrapling] 工作台面板已注册:', boot.url)
33
+ } catch (error) {
34
+ console.warn('[dsh-scrapling] 面板注册失败(工作台仍可直接访问):', error && error.message)
35
+ }
36
+
18
37
  ctx.effect(function () {
19
38
  return function () {
20
39
  console.log('[dsh-scrapling] 客户端已卸载')
package/cordis.patch.yml CHANGED
@@ -1,9 +1,16 @@
1
1
  # dsh-scrapling bundle patch
2
2
  # Scrapling 网页抓取插件配置
3
+ #
4
+ # 配置项(cordis config → 环境变量 DSH_SCRAPLING_* → 默认值):
5
+ # enabled 是否启用 DSH_SCRAPLING_ENABLED true
6
+ # port 工作台端口 DSH_SCRAPLING_PORT 39640
7
+ # host 监听地址 DSH_SCRAPLING_HOST 127.0.0.1
8
+ # timeoutMs 请求超时(ms) DSH_SCRAPLING_TIMEOUT_MS 20000
9
+ # workbench 是否拉起工作台 DSH_SCRAPLING_WORKBENCH true
3
10
 
4
11
  - insert:
5
12
  - id: scrapling-host
6
13
  name: "@capyclaw/scrapling"
7
14
  config:
8
- # Scrapling 配置选项
9
15
  enabled: true
16
+ port: 39640
package/demo/news.html ADDED
@@ -0,0 +1,53 @@
1
+ <!DOCTYPE html>
2
+ <html lang="zh-CN">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>科技早报 · 演示新闻站</title>
6
+ <style>
7
+ body { font-family: "Microsoft YaHei", sans-serif; max-width: 800px; margin: 40px auto; color: #222; }
8
+ h1 { font-size: 26px; }
9
+ .article { border-bottom: 1px solid #e5e5e5; padding: 14px 0; }
10
+ .article h2 { font-size: 18px; margin: 0 0 6px; }
11
+ .article h2 a { color: #0b5394; text-decoration: none; }
12
+ .article .excerpt { color: #555; font-size: 14px; margin: 4px 0 8px; }
13
+ .article .info { color: #999; font-size: 12px; }
14
+ .article .info .category { background: #e8f0fe; color: #1a73e8; border-radius: 3px; padding: 1px 8px; margin-right: 8px; }
15
+ .article.featured h2 a { color: #b45309; }
16
+ .article.featured h2::before { content: "★ "; color: #e8a33d; }
17
+ </style>
18
+ </head>
19
+ <body>
20
+ <h1>科技早报</h1>
21
+ <p class="intro">内置演示新闻页:练习链接、日期与分类的选择器提取。</p>
22
+
23
+ <div class="article-list">
24
+ <article class="article featured" data-id="n101">
25
+ <h2><a href="/article/n101">端侧大模型进入手机:一场内存与算力的平衡术</a></h2>
26
+ <p class="excerpt">随着专用 NPU 的普及,手机厂商开始在本地运行十亿参数级模型,隐私与延迟成为最大卖点。</p>
27
+ <div class="info"><span class="category">AI</span><time class="date" datetime="2026-11-04">2026-11-04</time> · 记者:林一</div>
28
+ </article>
29
+ <article class="article" data-id="n102">
30
+ <h2><a href="/article/n102">开源爬虫框架年度盘点:谁在替代 Scrapy?</a></h2>
31
+ <p class="excerpt">从反反爬能力到自适应选择器,新一代抓取库正在重新定义「数据采集」的工程边界。</p>
32
+ <div class="info"><span class="category">开源</span><time class="date" datetime="2026-11-03">2026-11-03</time> · 记者:周未</div>
33
+ </article>
34
+ <article class="article" data-id="n103">
35
+ <h2><a href="/article/n103">WebAssembly 在数据处理的第三个落地年头</a></h2>
36
+ <p class="excerpt">把解析器编译到浏览器端运行,正成为数据工具规避后端部署的常见路径。</p>
37
+ <div class="info"><span class="category">前端</span><time class="date" datetime="2026-11-02">2026-11-02</time> · 记者:陈默</div>
38
+ </article>
39
+ <article class="article" data-id="n104">
40
+ <h2><a href="/article/n104">本地优先软件回潮:为什么工具都想摆脱云端?</a></h2>
41
+ <p class="excerpt">断网可用、数据自持——本地优先正从极客理念变成产品卖点。</p>
42
+ <div class="info"><span class="category">产品</span><time class="date" datetime="2026-11-01">2026-11-01</time> · 记者:林一</div>
43
+ </article>
44
+ <article class="article" data-id="n105">
45
+ <h2><a href="/article/n105">数据合规新规下的采集边界:工程师需要知道的五件事</a></h2>
46
+ <p class="excerpt">robots.txt 之外,新的合规要求正在改变爬虫的默认行为设计。</p>
47
+ <div class="info"><span class="category">合规</span><time class="date" datetime="2026-10-31">2026-10-31</time> · 记者:周未</div>
48
+ </article>
49
+ </div>
50
+
51
+ <footer class="site-footer"><p>内置演示页 · 用于 DSH Scrapling 工作台演示</p></footer>
52
+ </body>
53
+ </html>
@@ -0,0 +1,68 @@
1
+ <!DOCTYPE html>
2
+ <html lang="zh-CN">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>好物清单 · 演示商城</title>
6
+ <style>
7
+ body { font-family: "Microsoft YaHei", sans-serif; max-width: 900px; margin: 40px auto; color: #2c2c2c; background: #f6f7fb; }
8
+ h1 { color: #1f3a93; }
9
+ .grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
10
+ .product { background: #fff; border-radius: 8px; padding: 16px; box-shadow: 0 1px 4px rgba(0,0,0,.08); }
11
+ .product .name { font-weight: bold; font-size: 16px; }
12
+ .product .price { color: #c0392b; font-size: 20px; margin: 6px 0; }
13
+ .product .meta { color: #777; font-size: 13px; }
14
+ .rating { color: #e67e22; }
15
+ .out-of-stock .name::after { content: "(缺货)"; color: #999; }
16
+ table.summary { border-collapse: collapse; margin-top: 24px; width: 100%; background: #fff; }
17
+ table.summary th, table.summary td { border: 1px solid #ddd; padding: 6px 10px; text-align: left; font-size: 14px; }
18
+ </style>
19
+ </head>
20
+ <body>
21
+ <h1>好物清单</h1>
22
+ <p class="intro">内置演示商城页:练习表格与卡片两种结构的 CSS 选择器提取。</p>
23
+
24
+ <div class="grid">
25
+ <div class="product" data-sku="A-1001">
26
+ <div class="name">机械键盘 87 键</div>
27
+ <div class="price">¥399.00</div>
28
+ <div class="meta"><span class="rating" data-score="4.8">评分 4.8</span> · 月销 1200+ · <span class="stock">有货</span></div>
29
+ </div>
30
+ <div class="product out-of-stock" data-sku="A-1002">
31
+ <div class="name">无线静音鼠标</div>
32
+ <div class="price">¥129.00</div>
33
+ <div class="meta"><span class="rating" data-score="4.5">评分 4.5</span> · 月销 800+ · <span class="stock">缺货</span></div>
34
+ </div>
35
+ <div class="product" data-sku="A-1003">
36
+ <div class="name">4K 显示器 27 寸</div>
37
+ <div class="price">¥2199.00</div>
38
+ <div class="meta"><span class="rating" data-score="4.9">评分 4.9</span> · 月销 300+ · <span class="stock">有货</span></div>
39
+ </div>
40
+ <div class="product" data-sku="A-1004">
41
+ <div class="name">USB-C 扩展坞</div>
42
+ <div class="price">¥259.00</div>
43
+ <div class="meta"><span class="rating" data-score="4.6">评分 4.6</span> · 月销 2100+ · <span class="stock">有货</span></div>
44
+ </div>
45
+ <div class="product" data-sku="A-1005">
46
+ <div class="name">降噪蓝牙耳机</div>
47
+ <div class="price">¥799.00</div>
48
+ <div class="meta"><span class="rating" data-score="4.7">评分 4.7</span> · 月销 560+ · <span class="stock">有货</span></div>
49
+ </div>
50
+ <div class="product out-of-stock" data-sku="A-1006">
51
+ <div class="name">桌面升降支架</div>
52
+ <div class="price">¥459.00</div>
53
+ <div class="meta"><span class="rating" data-score="4.4">评分 4.4</span> · 月销 90+ · <span class="stock">缺货</span></div>
54
+ </div>
55
+ </div>
56
+
57
+ <table class="summary">
58
+ <thead><tr><th>商品</th><th>价格</th><th>评分</th></tr></thead>
59
+ <tbody>
60
+ <tr><td>机械键盘 87 键</td><td>399.00</td><td>4.8</td></tr>
61
+ <tr><td>无线静音鼠标</td><td>129.00</td><td>4.5</td></tr>
62
+ <tr><td>4K 显示器 27 寸</td><td>2199.00</td><td>4.9</td></tr>
63
+ </tbody>
64
+ </table>
65
+
66
+ <footer class="site-footer"><p>内置演示页 · 用于 DSH Scrapling 工作台演示</p></footer>
67
+ </body>
68
+ </html>
@@ -0,0 +1,72 @@
1
+ <!DOCTYPE html>
2
+ <html lang="zh-CN">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>每日名言 · 演示站</title>
6
+ <style>
7
+ body { font-family: "Microsoft YaHei", sans-serif; max-width: 760px; margin: 40px auto; color: #333; background: #faf8f4; }
8
+ h1 { border-bottom: 3px solid #e8a33d; padding-bottom: 10px; }
9
+ .quote { border-left: 4px solid #e8a33d; background: #fff; margin: 18px 0; padding: 14px 18px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
10
+ .quote .text { font-size: 17px; }
11
+ .quote .author { color: #b3541e; margin-top: 6px; }
12
+ .quote .tags { margin-top: 8px; }
13
+ .tag { display: inline-block; background: #f0e6d2; color: #7a5c1e; border-radius: 10px; padding: 1px 10px; margin-right: 6px; font-size: 13px; text-decoration: none; }
14
+ .pager { margin: 24px 0; }
15
+ </style>
16
+ </head>
17
+ <body>
18
+ <h1>每日名言</h1>
19
+ <p class="intro">这是一个内置演示页面:无需外网,用来体验 DSH 的完整爬取流程。</p>
20
+
21
+ <div class="quote-list">
22
+ <div class="quote" data-id="1">
23
+ <span class="text">生活不是等待暴风雨过去,而是学会在雨中跳舞。</span>
24
+ <span class="author">佚名</span>
25
+ <div class="tags"><a class="tag" href="/tag/生活/1">生活</a><a class="tag" href="/tag/态度/1">态度</a></div>
26
+ </div>
27
+ <div class="quote" data-id="2">
28
+ <span class="text">种一棵树最好的时间是十年前,其次是现在。</span>
29
+ <span class="author">非洲谚语</span>
30
+ <div class="tags"><a class="tag" href="/tag/行动/1">行动</a><a class="tag" href="/tag/时间/1">时间</a></div>
31
+ </div>
32
+ <div class="quote" data-id="3">
33
+ <span class="text">简单是复杂的最高境界。</span>
34
+ <span class="author">达·芬奇</span>
35
+ <div class="tags"><a class="tag" href="/tag/设计/1">设计</a><a class="tag" href="/tag/简洁/1">简洁</a></div>
36
+ </div>
37
+ <div class="quote" data-id="4">
38
+ <span class="text">知道为什么而活的人,便能生存。</span>
39
+ <span class="author">尼采</span>
40
+ <div class="tags"><a class="tag" href="/tag/哲学/1">哲学</a></div>
41
+ </div>
42
+ <div class="quote" data-id="5">
43
+ <span class="text">千里之行,始于足下。</span>
44
+ <span class="author">老子</span>
45
+ <div class="tags"><a class="tag" href="/tag/行动/1">行动</a><a class="tag" href="/tag/古典/1">古典</a></div>
46
+ </div>
47
+ <div class="quote" data-id="6">
48
+ <span class="text">我们必须知道,我们必将知道。</span>
49
+ <span class="author">希尔伯特</span>
50
+ <div class="tags"><a class="tag" href="/tag/数学/1">数学</a><a class="tag" href="/tag/求知/1">求知</a></div>
51
+ </div>
52
+ <div class="quote" data-id="7">
53
+ <span class="text">凡是过往,皆为序章。</span>
54
+ <span class="author">莎士比亚</span>
55
+ <div class="tags"><a class="tag" href="/tag/文学/1">文学</a><a class="tag" href="/tag/希望/1">希望</a></div>
56
+ </div>
57
+ <div class="quote" data-id="8">
58
+ <span class="text">唯一真正的错误是我们从中学不到任何东西的错误。</span>
59
+ <span class="author">亨利·福特</span>
60
+ <div class="tags"><a class="tag" href="/tag/成长/1">成长</a></div>
61
+ </div>
62
+ </div>
63
+
64
+ <nav class="pager">
65
+ <a class="next" href="/demo/quotes.html?page=2">下一页 →</a>
66
+ </nav>
67
+
68
+ <footer class="site-footer">
69
+ <p>内置演示页 · 结构参考 quotes.toscrape.com · 用于 DSH Scrapling 工作台演示</p>
70
+ </footer>
71
+ </body>
72
+ </html>