diff --git a/.gitignore b/.gitignore index 36ef842..adc5504 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ __pycache__/ # Local runtime config (use template file for repo) crawler_config.json +crawler_verse.json # Local temporary configs tmp_*.json diff --git a/README.md b/README.md index 9ca63d3..7e50c1e 100644 --- a/README.md +++ b/README.md @@ -7,12 +7,14 @@ ## 功能特性 -- 支持抓取常见文档站(VitePress / Docusaurus 结构) +- 支持抓取常见文档站(VitePress / Docusaurus / MkDocs 结构) - 支持多文档根路径自动识别(如 `/guide`、`/components`) - 支持“根路径 404,但叶子文档可访问”的站点结构 - 导航结构尽量贴近源站层级(一级/二级) +- 侧边栏标题自动中文化(覆盖常见技术术语) - 详细日志与保活输出(当前阶段、URL、进度、速率、ETA) -- 一键预览本地 HTML 文档站 +- 一键预览本地 HTML 文档站(支持暗色/亮色模式) +- 支持将抓取结果导出为单个自包含 HTML 文件 - 输出标准 Markdown 目录,便于后续二次加工 --- @@ -74,8 +76,10 @@ run_crawler.bat 菜单: - `1` 抓取并构建站点 -- `2` 预览本地站点 +- `2` 预览本地站点(含暗色模式切换) - `3` 查看状态 +- `4` 导出单文件 HTML +- `5` 切换配置文件(`crawler*.json`) - `0` 退出 --- diff --git a/docs_crawler.py b/docs_crawler.py index 992f017..081a444 100644 --- a/docs_crawler.py +++ b/docs_crawler.py @@ -331,7 +331,14 @@ def _looks_like_docs_html(page_html: str, docs_root: str) -> bool: if any(m.lower() in text.lower() for m in markers): return True docs_root = "/" + (docs_root or "/docs").strip("/") - if re.search(rf'href=(?:"|\')({re.escape(docs_root)}/)', text, re.I): + # Check for relative or absolute links under docs_root (quoted or unquoted) + escaped = re.escape(docs_root) + if re.search(rf'href=(?:"|\')?(?:https?://[^/]+)?{escaped}/', text, re.I): + return True + # Last-resort: accept any page with