141 lines
4.6 KiB
Markdown
141 lines
4.6 KiB
Markdown
---
|
||
phase: 4
|
||
plan: 2
|
||
wave: 2
|
||
title: "废弃 app/services/crawler/ 私有复制文件 + jobs_spider/ 标记废弃"
|
||
depends_on:
|
||
- "04-01-PLAN.md"
|
||
files_modified:
|
||
- app/services/crawler/_base.py
|
||
- app/services/crawler/_http_client.py
|
||
- app/services/crawler/_boss_api.py
|
||
- app/services/crawler/_boss_client.py
|
||
- app/services/crawler/_boss_sign.py
|
||
- app/services/crawler/_job51_api.py
|
||
- app/services/crawler/_job51_client.py
|
||
- app/services/crawler/_job51_sign.py
|
||
- app/services/crawler/_zhilian_api.py
|
||
- app/services/crawler/_zhilian_client.py
|
||
- app/services/crawler/_zhilian_sign.py
|
||
- jobs_spider/boss/boos_api.py
|
||
autonomous: true
|
||
requirements:
|
||
- ARCH-08
|
||
---
|
||
|
||
# Phase 4 Plan 02: 废弃私有复制文件 + jobs_spider/ 标记废弃
|
||
|
||
## Objective
|
||
|
||
Plan 01 执行后,`app/services/crawler/` 的 11 个私有复制文件不再被任何 facade 引用。
|
||
本 Plan 将这些文件添加 `DEPRECATED` 文件头注释,表明它们已废弃,并对 `jobs_spider/` 做同样处理。
|
||
|
||
**注意:** 策略是"添加废弃标记"而非"直接删除",避免第三方未知调用方受影响。
|
||
未来可在下一个里程碑中删除这些文件。
|
||
|
||
## Must Haves
|
||
|
||
- [ ] 11 个私有文件(`_base.py`、`_http_client.py`、`_boss_*`、`_job51_*`、`_zhilian_*`)文件头添加 `## DEPRECATED` 注释
|
||
- [ ] `jobs_spider/boss/boos_api.py` 文件头添加 `## DEPRECATED` 注释
|
||
- [ ] `jobs_spider/CLAUDE.md` 添加废弃声明(如有)
|
||
- [ ] `pytest tests/ -v` 全部通过(废弃标记不影响 import)
|
||
|
||
---
|
||
|
||
## Wave 2(依赖 Plan 01 完成)
|
||
|
||
### Task 2.1: 为 _base.py 和 _http_client.py 添加废弃头
|
||
|
||
<action>
|
||
在 `app/services/crawler/_base.py` 文件顶部(第 1 行前)插入:
|
||
```python
|
||
"""
|
||
⚠️ DEPRECATED — 2026-03-21
|
||
|
||
此文件是 crawler_core.base 的手工复制,已废弃。
|
||
请改用: from crawler_core.base import Result, BaseFetcher, BaseSearcher
|
||
将在下一里程碑中删除。
|
||
"""
|
||
```
|
||
|
||
在 `app/services/crawler/_http_client.py` 文件顶部插入:
|
||
```python
|
||
"""
|
||
⚠️ DEPRECATED — 2026-03-21
|
||
|
||
此文件是 crawler_core.http_client 的手工复制,已废弃。
|
||
请改用: from crawler_core.http_client import HTTPClient
|
||
将在下一里程碑中删除。
|
||
"""
|
||
```
|
||
</action>
|
||
|
||
---
|
||
|
||
### Task 2.2: 为 9 个平台私有文件添加废弃头
|
||
|
||
<action>
|
||
分别为以下文件在文件头(原 docstring 的第一行)插入 `⚠️ DEPRECATED — 2026-03-21\n\n此文件已废弃,请改用 spiderJobs.platforms.* 相应模块。` 或更新已有 docstring 中的说明文字:
|
||
|
||
- `app/services/crawler/_boss_api.py`(已有 docstring "复制自...",在其下方添加废弃行)
|
||
- `app/services/crawler/_boss_client.py`
|
||
- `app/services/crawler/_boss_sign.py`
|
||
- `app/services/crawler/_job51_api.py`
|
||
- `app/services/crawler/_job51_client.py`
|
||
- `app/services/crawler/_zhilian_api.py`(需要先读文件确认 docstring)
|
||
- `app/services/crawler/_zhilian_client.py`
|
||
- `app/services/crawler/_zhilian_sign.py`
|
||
|
||
统一格式:在原 docstring 下方第二行插入:
|
||
`⚠️ DEPRECATED — 2026-03-21. 请改用 spiderJobs.platforms.{boss|job51|zhilian} 对应文件。`
|
||
</action>
|
||
|
||
---
|
||
|
||
### Task 2.3: 标记 jobs_spider/ 旧框架废弃
|
||
|
||
<action>
|
||
1. 在 `jobs_spider/boss/boos_api.py` 文件最顶部(第 1 行前)插入注释块:
|
||
```python
|
||
# ⚠️ DEPRECATED — 2026-03-21
|
||
# 此文件是最旧的 Boss 爬虫实现,已由 spiderJobs/platforms/boss/ + crawler_core 替代。
|
||
# 不再接受新的生产流量,保留仅供历史参考。
|
||
#
|
||
```
|
||
|
||
2. 检查 `jobs_spider/CLAUDE.md` 是否存在(通过 list_dir 查看),若存在则在顶部添加废弃说明;
|
||
若不存在则创建,内容为:
|
||
```markdown
|
||
# ⚠️ DEPRECATED
|
||
|
||
**废弃时间:** 2026-03-21
|
||
|
||
`jobs_spider/` 目录下的所有文件已由以下模块替代,不再维护:
|
||
- `spiderJobs/platforms/boss/` + `crawler_core` — Boss 直聘
|
||
- `spiderJobs/platforms/job51/` + `crawler_core/qcwy/` — 前程无忧
|
||
- `spiderJobs/platforms/zhilian/` + `crawler_core/zhilian/` — 智联招聘
|
||
|
||
文件保留仅供历史参考,将在下一里程碑中删除。
|
||
```
|
||
</action>
|
||
|
||
---
|
||
|
||
## Verification
|
||
|
||
```bash
|
||
# 1. 确认 facade 文件不再引用私有文件
|
||
grep -rn "from app.services.crawler._" app/services/crawler/boss.py \
|
||
app/services/crawler/qcwy.py app/services/crawler/zhilian.py \
|
||
&& echo "❌ 仍有旧导入" || echo "✅ facade 无旧导入"
|
||
|
||
# 2. 确认废弃标记存在
|
||
grep -l "DEPRECATED" app/services/crawler/_base.py \
|
||
app/services/crawler/_boss_api.py \
|
||
jobs_spider/boss/boos_api.py \
|
||
&& echo "✅ 废弃标记存在"
|
||
|
||
# 3. 全量回归(废弃标记不影响 import)
|
||
pipenv run python -m pytest tests/ -v --tb=short
|
||
```
|