Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

[Bug]: PathDepthScorer counts query and fragment slashes as path levels

已关闭 适合新手
#2,443 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 3 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
78/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
python
领域
backend

调研方向

从 crawl4ai.deep_crawling.scorers 中的 PathDepthScorer 开始,并使用 issue 中的复现步骤,将 /docs/guide 与附加查询和片段后缀的相同路径进行比较。检查后缀末尾的斜杠不会影响路径深度,并且只有 authority 的 URL 加上查询 URL 不会被视为具有路径。运行 issue 中描述的 scorer 回归用例;当后缀用例通过,且指定的对照项和现有深度算法保持不变时,即表示完成。

由索引模型根据 Issue 内容生成。

描述

crawl4ai version

0.9.5, current develop at 240d9cd050b26607355a3bcf977aa73660069590.

Expected Behavior

PathDepthScorer should measure the URL path. Adding query parameters or a fragment should not change the path-depth score, even when those suffixes contain slashes or another URL.

Current Behavior

The scorer locates the first slash after the scheme and counts the entire remaining string, including query/fragment text. With optimal_depth=2, /docs/guide scores 1.0 but /docs/guide?next=/a/b/c scores 0.25. An authority-only URL whose query contains another URL can also be scored as if it had a path. This changes the priority assigned to links during deep crawling.

Reproduction
from crawl4ai.deep_crawling.scorers import PathDepthScorer

scorer = PathDepthScorer(optimal_depth=2)
print(scorer.score("https://example.com/docs/guide"))
print(scorer.score("https://example.com/docs/guide?next=/a/b/c"))
# Expected: 1.0, 1.0. Actual: 1.0, 0.25.

The real public scorer reproduced seven failing regression cases and five passing controls on unmodified develop. Query-only, fragment-only, combined suffixes, and a query URL without a preceding path are affected. Root/path controls, encoded characters and repeated separators are covered.

Proposed Fix

Discard the literal query and fragment suffixes before the existing path lookup. Keep the current depth algorithm, weighting, statistics and caches. This is separate from #2405 (file-extension scoring) and the old queue-direction problem #1080/#1081.

Environment

Windows / Python 3.12.14. Pure local scorer calls, with the installed dependencies and actual current checkout import. No browser, external website, model or network request is needed for the reproduction.

AI assistance: Codex identified this during a source audit for contribution opportunities, ran the original-code reproduction and prepared the minimal repair. No human review is claimed.

主要语言
Python
星标
86.4k
派生
9k
平均合并
4 天 5 小时
30 天内合并 PR
23

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

unclecode/crawl4ai 的其他 Issue

查看 unclecode/crawl4ai 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。