Relative <base href> produces scheme-less extracted links
Maintainer thường phản hồi trong vòng 1 ngà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
- 25/100
Hướng nghiên cứu
The relevant code is LXMLWebScrapingStrategy._process_element() in the content scraping strategy module, which reads <base href> and uses it as url without resolving it, plus the normalize_url helper it should match. Reproduce with the snippet in the issue to confirm the scheme-less /sub/page.html output. Done means relative and absolute <base href> values both yield absolute internal links. Pull request #2552 is already open against this issue, so check with the maintainers before starting.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Description
LXMLWebScrapingStrategy._process_element() reads <base href> and assigns it to url as-is. When the page declares a relative base (e.g. <base href="/sub/">), every relative link is resolved against that relative string, so the extracted links come out scheme- and host-less (/sub/page.html) even though the same document without a <base> element yields an absolute link.
Reproduction
import sys
from lxml import html as lhtml
from crawl4ai.content_scraping_strategy import LXMLWebScrapingStrategy
strategy = LXMLWebScrapingStrategy()
html = "<html><head><base href='/sub/'></head><body><a href='page.html'>Page</a></body></html>"
result = strategy.process_element("https://example.com/app/index.html", lhtml.fromstring(html))
print(list(result["internal_links_dict"]))
- Actual:
['/sub/page.html'] - Expected:
['https://example.com/sub/page.html']
Absolute <base href="https://cdn.example.com/docs/"> behaves as before.
Expected fix
Resolve the declared base against the page URL with urljoin(url, base_href) before it is used, so relative and absolute <base> values both produce absolute links. This is the same resolution normalize_url already performs when no <base> is present.
I will open a small PR with a regression test covering root-relative, document-relative, absolute and missing <base> values.
- Ngôn ngữ chính
- Python
- Star
- 87.2k
- Fork
- 9.1k
- Merge trung bình
- 1 ngày 6 giờ
- Pull request đã merge (30 ngày)
- 25
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của unclecode/crawl4ai
-
BUG: UserAgentGenerator.generate ignores browser_type and returns a random browser stackCó thể đã có người làm @HhH666-ux đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug]: Hardened docker-compose (read_only) keeps full Chromium from starting: crashpad needs a writable ~/.configCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở🐞 Bug 📌 Root caused
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
unclecode/crawl4ai#2494 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Feature]: Crawl4aiDockerClient has no public option for the API token the 0.9 server requiresĐang mở⚙ Done ✨ Enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
Maintainer thường phản hồi trong vòng 1 ngày
-
⚙ Done 🐞 Bug 📌 Root caused
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug]: PDF images saved with save_images_locally=True come back with an empty src in result.mediaĐang mở⚙ Done 🐞 Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
unclecode/crawl4ai#2469 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của unclecode/crawl4ai
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
521xueweihan/HelloGitHub#4385 ·
-
🐛 bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
pdm-project/pdm#4012 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 82/100
pollen-robotics/reachy_mini_conversation_app#611 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 91/100
aws-samples/sample-per-model-bedrock#913 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
lesson-submission pending-review
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
Ikalus1988/MisakaNet#5115 ·
Maintainer thường phản hồi trong vòng 1 ngày