web2json-agent 1.0.0__tar.gz
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.
- web2json_agent-1.0.0/.env.example +52 -0
- web2json_agent-1.0.0/LICENSE +21 -0
- web2json_agent-1.0.0/MANIFEST.in +21 -0
- web2json_agent-1.0.0/PKG-INFO +348 -0
- web2json_agent-1.0.0/README.md +306 -0
- web2json_agent-1.0.0/agent/__init__.py +14 -0
- web2json_agent-1.0.0/agent/executor.py +545 -0
- web2json_agent-1.0.0/agent/orchestrator.py +128 -0
- web2json_agent-1.0.0/agent/planner.py +61 -0
- web2json_agent-1.0.0/cli.py +195 -0
- web2json_agent-1.0.0/config/__init__.py +4 -0
- web2json_agent-1.0.0/config/settings.py +72 -0
- web2json_agent-1.0.0/config/validator.py +409 -0
- web2json_agent-1.0.0/main.py +137 -0
- web2json_agent-1.0.0/prompts/__init__.py +14 -0
- web2json_agent-1.0.0/prompts/code_generator.py +237 -0
- web2json_agent-1.0.0/prompts/schema_extraction.py +169 -0
- web2json_agent-1.0.0/prompts/schema_merge.py +168 -0
- web2json_agent-1.0.0/pyproject.toml +104 -0
- web2json_agent-1.0.0/requirements.txt +21 -0
- web2json_agent-1.0.0/setup.cfg +4 -0
- web2json_agent-1.0.0/tools/__init__.py +24 -0
- web2json_agent-1.0.0/tools/code_generator.py +134 -0
- web2json_agent-1.0.0/tools/html_simplifier.py +405 -0
- web2json_agent-1.0.0/tools/schema_extraction.py +264 -0
- web2json_agent-1.0.0/tools/webpage_screenshot.py +92 -0
- web2json_agent-1.0.0/tools/webpage_source.py +46 -0
- web2json_agent-1.0.0/utils/__init__.py +6 -0
- web2json_agent-1.0.0/utils/llm_client.py +350 -0
- web2json_agent-1.0.0/web2json_agent.egg-info/PKG-INFO +348 -0
- web2json_agent-1.0.0/web2json_agent.egg-info/SOURCES.txt +33 -0
- web2json_agent-1.0.0/web2json_agent.egg-info/dependency_links.txt +1 -0
- web2json_agent-1.0.0/web2json_agent.egg-info/entry_points.txt +2 -0
- web2json_agent-1.0.0/web2json_agent.egg-info/requires.txt +20 -0
- web2json_agent-1.0.0/web2json_agent.egg-info/top_level.txt +7 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# ============================================
|
|
2
|
+
# web2json-agent 环境配置文件
|
|
3
|
+
# ============================================
|
|
4
|
+
# 使用方法: cp .env.example .env
|
|
5
|
+
# 然后修改 .env 文件中的配置值
|
|
6
|
+
|
|
7
|
+
# ============================================
|
|
8
|
+
# API 配置(必填,其他可选填,推荐使用OPENAI中转节点)
|
|
9
|
+
# ============================================
|
|
10
|
+
OPENAI_API_KEY=your_api_key_here
|
|
11
|
+
OPENAI_API_BASE=https://api.openai.com/v1
|
|
12
|
+
|
|
13
|
+
# ============================================
|
|
14
|
+
# 模型配置(可选,推荐使用默认值)
|
|
15
|
+
# ============================================
|
|
16
|
+
|
|
17
|
+
# 默认模型(通用场景,如Schema提取和合并)
|
|
18
|
+
DEFAULT_MODEL=claude-sonnet-4-5-20250929
|
|
19
|
+
DEFAULT_TEMPERATURE=0.3
|
|
20
|
+
|
|
21
|
+
# Agent 规划和执行
|
|
22
|
+
AGENT_MODEL=claude-sonnet-4-5-20250929
|
|
23
|
+
AGENT_TEMPERATURE=0
|
|
24
|
+
|
|
25
|
+
# 代码生成
|
|
26
|
+
CODE_GEN_MODEL=claude-sonnet-4-5-20250929
|
|
27
|
+
CODE_GEN_TEMPERATURE=0.3
|
|
28
|
+
CODE_GEN_MAX_TOKENS=16384
|
|
29
|
+
|
|
30
|
+
# 视觉理解(图片转JSON)
|
|
31
|
+
VISION_MODEL=qwen-vl-max
|
|
32
|
+
VISION_TEMPERATURE=0
|
|
33
|
+
VISION_MAX_TOKENS=16384
|
|
34
|
+
|
|
35
|
+
# ============================================
|
|
36
|
+
# 浏览器配置(可选)
|
|
37
|
+
# ============================================
|
|
38
|
+
HEADLESS=true
|
|
39
|
+
TIMEOUT=30000
|
|
40
|
+
SCREENSHOT_FULL_PAGE=true
|
|
41
|
+
|
|
42
|
+
# ============================================
|
|
43
|
+
# HTML精简配置(可选)
|
|
44
|
+
# ============================================
|
|
45
|
+
# 精简模式: xpath, aggressive, conservative
|
|
46
|
+
# - xpath: 为Schema提取优化,保留定位属性和内容标签(推荐)
|
|
47
|
+
# - aggressive: 激进模式,最大化压缩
|
|
48
|
+
# - conservative: 保守模式,保留更多原始结构
|
|
49
|
+
HTML_SIMPLIFY_MODE=xpath
|
|
50
|
+
|
|
51
|
+
# 保留的HTML属性(逗号分隔,仅xpath和aggressive模式有效)
|
|
52
|
+
HTML_KEEP_ATTRS=class,id,href,src,data-id
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 web2json-agent Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# 包含必要的文档和配置文件
|
|
2
|
+
include README.md
|
|
3
|
+
include LICENSE
|
|
4
|
+
include requirements.txt
|
|
5
|
+
include .env.example
|
|
6
|
+
include install_playwright.sh
|
|
7
|
+
|
|
8
|
+
# 排除不必要的文件和目录
|
|
9
|
+
global-exclude __pycache__
|
|
10
|
+
global-exclude *.py[cod]
|
|
11
|
+
global-exclude *.so
|
|
12
|
+
global-exclude .DS_Store
|
|
13
|
+
|
|
14
|
+
prune output
|
|
15
|
+
prune logs
|
|
16
|
+
prune doc
|
|
17
|
+
prune input_url
|
|
18
|
+
prune input_stack_blog
|
|
19
|
+
prune .git
|
|
20
|
+
prune .idea
|
|
21
|
+
prune .pytest_cache
|
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: web2json-agent
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: 智能网页解析代码生成器 - 基于 AI 自动生成网页解析代码
|
|
5
|
+
Author-email: YangGuoqiang <1041206149@qq.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/ccprocessor/web2json-agent
|
|
8
|
+
Project-URL: Repository, https://github.com/ccprocessor/web2json-agent.git
|
|
9
|
+
Project-URL: Bug Tracker, https://github.com/ccprocessor/web2json-agent/issues
|
|
10
|
+
Keywords: web scraping,html parser,ai agent,code generation,langchain,web automation
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Topic :: Software Development :: Code Generators
|
|
17
|
+
Classifier: Topic :: Internet :: WWW/HTTP :: Indexing/Search
|
|
18
|
+
Classifier: Topic :: Text Processing :: Markup :: HTML
|
|
19
|
+
Requires-Python: >=3.12
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
Requires-Dist: langchain==1.0.1
|
|
23
|
+
Requires-Dist: langchain-core==1.0.5
|
|
24
|
+
Requires-Dist: langchain-openai==1.0.3
|
|
25
|
+
Requires-Dist: langchain-anthropic==1.1.0
|
|
26
|
+
Requires-Dist: openai==2.8.1
|
|
27
|
+
Requires-Dist: pydantic==2.10.3
|
|
28
|
+
Requires-Dist: pydantic-settings==2.6.1
|
|
29
|
+
Requires-Dist: python-dotenv==1.1.0
|
|
30
|
+
Requires-Dist: loguru==0.7.3
|
|
31
|
+
Requires-Dist: DrissionPage==4.1.1.2
|
|
32
|
+
Requires-Dist: beautifulsoup4==4.12.3
|
|
33
|
+
Requires-Dist: lxml==5.3.0
|
|
34
|
+
Requires-Dist: requests==2.32.3
|
|
35
|
+
Provides-Extra: dev
|
|
36
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
37
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
|
|
38
|
+
Requires-Dist: black>=23.0.0; extra == "dev"
|
|
39
|
+
Requires-Dist: flake8>=6.0.0; extra == "dev"
|
|
40
|
+
Requires-Dist: mypy>=1.0.0; extra == "dev"
|
|
41
|
+
Dynamic: license-file
|
|
42
|
+
|
|
43
|
+
# web2json-agent
|
|
44
|
+
|
|
45
|
+
智能网页解析代码生成器 - 基于 AI 自动生成网页解析代码
|
|
46
|
+
|
|
47
|
+
## 简介
|
|
48
|
+
|
|
49
|
+
**web2json-agent** 是一个基于 LangChain 的智能 Agent 系统,通过多模态 AI 自动分析网页结构并生成高质量的 Python 解析代码。
|
|
50
|
+
|
|
51
|
+
### 核心能力
|
|
52
|
+
|
|
53
|
+
提供几个示例 HTML 文件,Agent 自动完成:
|
|
54
|
+
|
|
55
|
+
1. 📁 读取本地HTML文件并精简
|
|
56
|
+
2. 📸 渲染HTML并截图(DrissionPage)
|
|
57
|
+
3. 🔍 双重Schema提取(HTML分析 + 视觉理解)
|
|
58
|
+
4. 🔄 智能Schema合并与优化
|
|
59
|
+
5. 💻 生成 BeautifulSoup 解析代码
|
|
60
|
+
|
|
61
|
+
### 适用场景
|
|
62
|
+
|
|
63
|
+
- 批量爬取同类型网页(博客、产品页、新闻等)
|
|
64
|
+
- 快速生成解析代码原型
|
|
65
|
+
- 减少手动编写解析器的时间
|
|
66
|
+
|
|
67
|
+
## 工作流程
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
本地HTML文件 → 任务规划 → Schema迭代阶段(对每个HTML)
|
|
71
|
+
├─ 读取HTML文件 + 截图(DrissionPage)
|
|
72
|
+
├─ HTML精简(减少token消耗)
|
|
73
|
+
├─ HTML → Schema(含xpath路径)
|
|
74
|
+
├─ 视觉 → Schema(含视觉描述)
|
|
75
|
+
└─ 合并两个Schema
|
|
76
|
+
↓
|
|
77
|
+
多Schema合并(筛选+修正+去重)→ 最终Schema
|
|
78
|
+
↓
|
|
79
|
+
代码迭代阶段 → 生成/优化解析代码 → 最终代码
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Schema迭代规则
|
|
83
|
+
|
|
84
|
+
**对于单个HTML(建议输入2~5个):**
|
|
85
|
+
1. **HTML分析**:从HTML代码提取Schema(字段名、说明、值示例、**xpath路径**)
|
|
86
|
+
2. **视觉分析**:从网页截图提取Schema(字段名、说明、值示例、**视觉描述**)
|
|
87
|
+
3. **Schema合并**:判断相同字段,合并xpath和visual_features
|
|
88
|
+
|
|
89
|
+
**处理完所有HTML后:**
|
|
90
|
+
4. **多Schema整合**:
|
|
91
|
+
- 去除无意义字段(广告、导航等)
|
|
92
|
+
- 修正字段结构(元信息归属、列表字段识别)
|
|
93
|
+
- 合并xpath路径(每个字段包含多个xpath,增强鲁棒性)
|
|
94
|
+
- 生成最终Schema
|
|
95
|
+
|
|
96
|
+
### 核心技术
|
|
97
|
+
|
|
98
|
+
- **双重视角Schema提取**:同时从HTML代码和视觉布局提取Schema,互相补充
|
|
99
|
+
- **多路径鲁棒性**:每个字段保留多个xpath提取路径,适应不同页面结构
|
|
100
|
+
- **智能Schema合并**:自动识别相同字段、修正字段类型、优化数据结构
|
|
101
|
+
- **HTML精简**:使用自定义HTML精简工具,减少token消耗,提升响应速度
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
## 安装
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
# 克隆项目
|
|
109
|
+
git clone https://github.com/ccprocessor/web2json-agent.git
|
|
110
|
+
cd web2json-agent
|
|
111
|
+
|
|
112
|
+
# 安装依赖
|
|
113
|
+
pip install -r requirements.txt
|
|
114
|
+
|
|
115
|
+
# 或使用可编辑模式(开发)
|
|
116
|
+
pip install -e .
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## ⚙️ 配置(重要!)
|
|
122
|
+
|
|
123
|
+
### 环境配置
|
|
124
|
+
|
|
125
|
+
**使用前必须先配置 .env 文件!**
|
|
126
|
+
|
|
127
|
+
1. **复制配置模板**
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
cp .env.example .env
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
2. **编辑 .env 文件,填入你的配置**
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
vim .env # 或使用其他编辑器
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
3. **必填配置项**
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
# API 配置(必需)
|
|
143
|
+
OPENAI_API_KEY=your_api_key_here # 你的 API 密钥
|
|
144
|
+
OPENAI_API_BASE=https://api.openai.com/v1 # API 地址
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
4. **可选配置项**(有默认值,可不修改)
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
# 模型配置
|
|
151
|
+
DEFAULT_MODEL=claude-sonnet-4-5-20250929 # 默认模型(通用场景)
|
|
152
|
+
AGENT_MODEL=claude-sonnet-4-5-20250929 # Agent 使用的模型
|
|
153
|
+
CODE_GEN_MODEL=claude-sonnet-4-5-20250929 # 代码生成模型
|
|
154
|
+
VISION_MODEL=qwen-vl-max # 视觉理解模型
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
更多配置选项请查看 `.env.example` 文件。
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
## 使用
|
|
162
|
+
|
|
163
|
+
### 命令行使用
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
# 查看帮助
|
|
167
|
+
web2json --help
|
|
168
|
+
|
|
169
|
+
# 从目录读取HTML文件(推荐)
|
|
170
|
+
web2json -d input_html/ -o output/blog
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Python 源码使用(开发模式)
|
|
174
|
+
|
|
175
|
+
如果从源码安装,也可以使用原始的 Python 方式:
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
# 从目录读取(推荐)
|
|
179
|
+
python main.py -d input_html/ -o output/blog
|
|
180
|
+
|
|
181
|
+
# 指定页面类型
|
|
182
|
+
python main.py -d input_html/ -o output/blog -t blog_article
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### HTML 文件准备
|
|
186
|
+
|
|
187
|
+
在 `input_html/` 目录下放置多个同类型网页的 HTML 源码文件:
|
|
188
|
+
|
|
189
|
+
```
|
|
190
|
+
input_html/
|
|
191
|
+
├── page1.html
|
|
192
|
+
├── page2.html
|
|
193
|
+
└── page3.html
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### 使用生成的解析器
|
|
197
|
+
|
|
198
|
+
```python
|
|
199
|
+
import sys
|
|
200
|
+
sys.path.insert(0, 'output/blog/parsers')
|
|
201
|
+
from generated_parser import WebPageParser
|
|
202
|
+
|
|
203
|
+
parser = WebPageParser()
|
|
204
|
+
data = parser.parse(html_content)
|
|
205
|
+
print(data)
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
---
|
|
209
|
+
|
|
210
|
+
## 项目结构
|
|
211
|
+
|
|
212
|
+
```
|
|
213
|
+
web2json-agent/
|
|
214
|
+
├── agent/ # Agent 核心模块
|
|
215
|
+
│ ├── planner.py # 任务规划
|
|
216
|
+
│ ├── executor.py # 任务执行(含Schema迭代逻辑)
|
|
217
|
+
│ └── orchestrator.py # Agent 编排
|
|
218
|
+
│
|
|
219
|
+
├── tools/ # LangChain Tools
|
|
220
|
+
│ ├── webpage_source.py # 读取本地HTML文件
|
|
221
|
+
│ ├── webpage_screenshot.py # 截图(DrissionPage)
|
|
222
|
+
│ ├── schema_extraction.py # Schema提取和合并
|
|
223
|
+
│ ├── html_simplifier.py # HTML精简工具
|
|
224
|
+
│ └── code_generator.py # 代码生成
|
|
225
|
+
│
|
|
226
|
+
├── prompts/ # Prompt 模板
|
|
227
|
+
│ ├── schema_extraction.py # Schema提取Prompt(HTML+视觉)
|
|
228
|
+
│ ├── schema_merge.py # Schema合并Prompt
|
|
229
|
+
│ └── code_generator.py # 代码生成Prompt
|
|
230
|
+
│
|
|
231
|
+
├── config/ # 配置
|
|
232
|
+
│ └── settings.py
|
|
233
|
+
│
|
|
234
|
+
├── utils/ # 工具类
|
|
235
|
+
│ └── llm_client.py # LLM 客户端
|
|
236
|
+
│
|
|
237
|
+
├── output/ # 输出目录
|
|
238
|
+
│ └── [domain]/
|
|
239
|
+
│ ├── screenshots/ # 网页截图
|
|
240
|
+
│ ├── html_original/ # 原始HTML
|
|
241
|
+
│ ├── html_simplified/ # 精简HTML
|
|
242
|
+
│ ├── schemas/ # Schema文件
|
|
243
|
+
│ │ ├── html_schema_round_{N}.json # HTML提取的Schema
|
|
244
|
+
│ │ ├── visual_schema_round_{N}.json # 视觉提取的Schema
|
|
245
|
+
│ │ ├── merged_schema_round_{N}.json # 合并后的Schema
|
|
246
|
+
│ │ └── final_schema.json # 最终Schema
|
|
247
|
+
│ ├── parsers/ # 生成的解析器
|
|
248
|
+
│ │ ├── parser_round_{N}.py # 每轮生成的解析器
|
|
249
|
+
│ │ └── final_parser.py # 最终解析器
|
|
250
|
+
│ └── result/ # 解析结果JSON
|
|
251
|
+
│
|
|
252
|
+
├── main.py # 命令行入口
|
|
253
|
+
└── requirements.txt # 依赖列表
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
---
|
|
257
|
+
|
|
258
|
+
## Schema格式说明
|
|
259
|
+
|
|
260
|
+
### 最终Schema结构
|
|
261
|
+
|
|
262
|
+
生成的`final_schema.json`包含每个字段的完整信息:
|
|
263
|
+
|
|
264
|
+
```json
|
|
265
|
+
{
|
|
266
|
+
"title": {
|
|
267
|
+
"type": "string",
|
|
268
|
+
"description": "文章标题",
|
|
269
|
+
"value_sample": "关于人工智能的未来",
|
|
270
|
+
"xpaths": [
|
|
271
|
+
"//h1[@class='article-title']/text()",
|
|
272
|
+
"//div[@class='title']/text()"
|
|
273
|
+
],
|
|
274
|
+
"visual_features": "位于页面上部中央区域,字体非常大且加粗,颜色为深色..."
|
|
275
|
+
},
|
|
276
|
+
"comments": {
|
|
277
|
+
"type": "array",
|
|
278
|
+
"description": "评论列表",
|
|
279
|
+
"value_sample": [{"user": "用户A", "text": "评论内容"}],
|
|
280
|
+
"xpaths": [
|
|
281
|
+
"//div[@class='comment-list']//div[@class='comment']",
|
|
282
|
+
"//ul[@class='comments']//li"
|
|
283
|
+
],
|
|
284
|
+
"visual_features": "位于正文下方,多个评论项垂直排列..."
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
### 字段说明
|
|
290
|
+
|
|
291
|
+
- **type**: 数据类型(string, number, array, object等)
|
|
292
|
+
- **description**: 字段的语义描述
|
|
293
|
+
- **value_sample**: 实际值示例(字符串截取前50字符)
|
|
294
|
+
- **xpaths**: 数组形式,包含多个可用的xpath提取路径(增强鲁棒性)
|
|
295
|
+
- **visual_features**: 视觉特征描述,包括位置、字体、颜色、布局等
|
|
296
|
+
|
|
297
|
+
---
|
|
298
|
+
|
|
299
|
+
## 返回值说明
|
|
300
|
+
|
|
301
|
+
`generate_parser()` 返回:
|
|
302
|
+
|
|
303
|
+
```python
|
|
304
|
+
{
|
|
305
|
+
'success': bool, # 是否成功
|
|
306
|
+
'parser_path': str, # 解析器路径
|
|
307
|
+
'config_path': str, # 配置文件路径
|
|
308
|
+
'validation_result': { # 验证结果
|
|
309
|
+
'success': bool,
|
|
310
|
+
'success_rate': float, # 成功率 (0.0-1.0)
|
|
311
|
+
'tests': [...] # 测试详情
|
|
312
|
+
},
|
|
313
|
+
'error': str # 错误信息(如果失败)
|
|
314
|
+
}
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
---
|
|
318
|
+
|
|
319
|
+
## 许可证
|
|
320
|
+
|
|
321
|
+
MIT License
|
|
322
|
+
|
|
323
|
+
---
|
|
324
|
+
|
|
325
|
+
**最后更新**: 2025-12-18
|
|
326
|
+
**版本**: 1.0.0
|
|
327
|
+
|
|
328
|
+
## 更新日志
|
|
329
|
+
|
|
330
|
+
### v1.0.0 (2025-12-18)
|
|
331
|
+
- ✨ 更清晰的模块结构:每个模块职责单一明确
|
|
332
|
+
- ✅ 完善CLI:新增配置验证和交互式设置
|
|
333
|
+
- ✨ 双重视角Schema提取(HTML + 视觉)
|
|
334
|
+
- ✨ 支持多xpath路径,增强解析鲁棒性
|
|
335
|
+
- ✨ 智能Schema合并和结构优化
|
|
336
|
+
- ✨ 集成HTML精简工具,减少token消耗以及冗余输入
|
|
337
|
+
|
|
338
|
+
### v0.2.0 (2025-12-12)
|
|
339
|
+
- ✨ 新增双重视角Schema提取(HTML + 视觉)
|
|
340
|
+
- ✨ 支持多xpath路径,增强解析鲁棒性
|
|
341
|
+
- ✨ 智能Schema合并和结构优化
|
|
342
|
+
- ✨ 集成HTML精简工具,减少token消耗以及冗余输入
|
|
343
|
+
|
|
344
|
+
### v0.1.0 (2025-11-26)
|
|
345
|
+
- 🎉 首次发布
|
|
346
|
+
- 基于视觉理解的Schema提取
|
|
347
|
+
- 自动代码生成和迭代优化
|
|
348
|
+
|