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.
This commit is contained in:
@@ -974,6 +974,8 @@ class JsonCssExtractionStrategy(JsonElementExtractionStrategy):
|
|||||||
return parsed_html.select(selector)
|
return parsed_html.select(selector)
|
||||||
|
|
||||||
def _get_elements(self, element, selector: str):
|
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)
|
return element.select(selector)
|
||||||
|
|
||||||
def _get_element_text(self, element) -> str:
|
def _get_element_text(self, element) -> str:
|
||||||
@@ -1048,5 +1050,3 @@ class JsonXPathExtractionStrategy(JsonElementExtractionStrategy):
|
|||||||
|
|
||||||
def _get_element_attribute(self, element, attribute: str):
|
def _get_element_attribute(self, element, attribute: str):
|
||||||
return element.get(attribute)
|
return element.get(attribute)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user