From ae376f15fb8b92701ea1a0b167f9a0e9c2d6804c Mon Sep 17 00:00:00 2001 From: UncleCode Date: Sun, 5 Jan 2025 19:39:15 +0800 Subject: [PATCH] docs(extraction): add clarifying comments for CSS selector behavior Add explanatory comments to JsonCssExtractionStrategy._get_elements() method to clarify that it returns all matching elements using select() instead of select_one(). This helps developers understand the method's behavior and its difference from single element selection. Removed trailing whitespace at end of file. --- crawl4ai/extraction_strategy.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crawl4ai/extraction_strategy.py b/crawl4ai/extraction_strategy.py index 1e9d9c79..3e688f13 100644 --- a/crawl4ai/extraction_strategy.py +++ b/crawl4ai/extraction_strategy.py @@ -974,6 +974,8 @@ class JsonCssExtractionStrategy(JsonElementExtractionStrategy): return parsed_html.select(selector) def _get_elements(self, element, selector: str): + # Return all matching elements using select() instead of select_one() + # This ensures that we get all elements that match the selector, not just the first one return element.select(selector) def _get_element_text(self, element) -> str: @@ -1048,5 +1050,3 @@ class JsonXPathExtractionStrategy(JsonElementExtractionStrategy): def _get_element_attribute(self, element, attribute: str): return element.get(attribute) - -