Official Crawl4AI Cloud: a hosted web scraping, extraction, and search API for AI agents. Free API key, 1,000 credits a month, no card. Fully open source: this repo is the Apache-2.0 crawler that powers it, and you can self-host it.
Python aiai-agentscrawl4ai-cloudcrawlerdata-extractionllmmarkdownmcpopen-sourceplaywrightpythonragscraperweb-crawlerweb-crawlingweb-scraping
fix(utils): keep fit_html body nested in an unclosed <noscript>
ntohidiba8b722df41f
diff --git a/crawl4ai/utils.py b/crawl4ai/utils.pyindex 03d55715..b2e2cba7 100644--- a/crawl4ai/utils.py+++ b/crawl4ai/utils.py@@ -3137,10 +3137,13 @@ def preprocess_html_for_schema(html_content, text_threshold=100, attr_value_threReturns:str: Preprocessed HTML content"""+ # Local import: content_scraping_strategy imports from this module.+ from .content_scraping_strategy import unwrap_orphaned_noscript+try:# Parse HTML with error recoveryparser = etree.HTMLParser(remove_comments=True, remove_blank_text=True)- tree = lhtml.fromstring(html_content, parser=parser)+ tree = lhtml.fromstring(unwrap_orphaned_noscript(html_content), parser=parser)# 1. Remove HEAD section (keep only BODY)head_elements = tree.xpath('//head')diff --git a/tests/test_unclosed_noscript.py b/tests/test_unclosed_noscript.pyindex f39c90d7..57d1d15d 100644--- a/tests/test_unclosed_noscript.py+++ b/tests/test_unclosed_noscript.py@@ -67,3 +67,11 @@ def test_unwrap_removes_tags_but_keeps_contents():assert "noscript" not in unwrappedassert "<h1>Unstunned. Hand slaughtered. Halal certified.</h1>" in unwrapped+++def test_fit_html_keeps_body_nested_in_unclosed_noscript():+ from crawl4ai.utils import preprocess_html_for_schema++ fit_html = preprocess_html_for_schema(DAMAGED_CAPTURE, text_threshold=500, max_size=300_000)++ assert "Unstunned. Hand slaughtered. Halal certified." in fit_html