Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đã đóng Phù hợp với người mới
#2,443 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 3 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
78/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
backend

Hướng nghiên cứu

Bắt đầu với PathDepthScorer trong crawl4ai.deep_crawling.scorers và dùng cách tái hiện trong issue để so sánh /docs/guide với cùng đường dẫn có thêm hậu tố truy vấn và phân mảnh. Kiểm tra rằng dấu gạch chéo ở cuối các hậu tố không ảnh hưởng đến độ sâu đường dẫn, và một URL chỉ có authority cùng với một URL truy vấn không bị coi là có đường dẫn. Chạy các trường hợp hồi quy của scorer được mô tả trong issue; công việc hoàn tất khi các trường hợp hậu tố đạt yêu cầu, còn các trường hợp đối chứng đã nêu và thuật toán độ sâu hiện có vẫn không thay đổi.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Python
Star
86.4k
Fork
9k
Merge trung bình
4 ngày 5 giờ
Pull request đã merge (30 ngày)
23

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của unclecode/crawl4ai

Tất cả issue của unclecode/crawl4ai

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.