Files
post_crawler/src/next_page_graph/prompts.py
T
2026-05-26 21:02:17 +08:00

81 lines
2.0 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""LLM 提示词"""
# 节点2: 找分页区域
FIND_PAGINATION_AREA_PROMPT = """分析以下 HTML,找到分页组件所在的区域。
## HTML
{html}
## 任务
找到包含分页组件的容器的 CSS 选择器。
## 判断建议
1. 包含页码数字(1, 2, 3...
2. 包含"上一页"/"下一页" ">" ">>" "<" "<<""或类似按钮
3. 常见 class: pagination, pager, pages, page-nav
4. 通常在页面底部
5. 根据你的专业判断最可能的元素
## 重要约束
1. 选择器必须唯一匹配一个元素
2. 如果基础选择器匹配多个元素,必须使用伪类精确定位,例如:
- .list:nth-child(2)
- .container > ul:first-of-type
- #main .job-list:nth-of-type(1)
3. 避免使用随机/哈希 class
## 输出
仅输出 JSON:
{{
"selector": "CSS选择器",
"reason": "选择原因" #字数限制30字
}}
找不到则:
{{
"selector": null,
"reason": "原因" #字数限制30字
}}
"""
# 节点3: 找下一页按钮
FIND_NEXT_BUTTON_PROMPT = """分析以下分页区域 HTML,找到可点击的"下一页"按钮。
## 分页区域 HTML
{pagination_html}
## 之前失败的选择器(避免使用)
{failed_selectors}
## 任务
找到可点击的"下一页"按钮的 CSS 选择器(相对于分页区域)。
## 判断依据
1. 文本包含: "下一页""Next""»"">"""""
2. Class 包含: next, pagination-next, next-page
3. 属性: [rel="next"], [aria-label*="next"]
4. 位置: 分页区域中靠右侧的可点击元素
5. 根据你的专业判断最可能的元素
## 必须排除(举例)
- disabled 属性的元素
- class 包含 disabled 的元素
- hidden 或 display:none 的元素
- 灰色/不可点击状态的按钮
如果下一页按钮存在但是 disabled 状态,返回 null。
## 输出
仅输出 JSON:
{{
"selector": "相对于分页区域的CSS选择器",
"reason": "选择原因" #字数限制30字
}}
找不到可点击的下一页按钮:
{{
"selector": null,
"reason": "原因(如:按钮disabled/仅一页/无按钮)" #字数限制30字
}}
"""