diff --git a/trafilatura/main_extractor.py b/trafilatura/main_extractor.py index 6431896c..5b6ad070 100644 --- a/trafilatura/main_extractor.py +++ b/trafilatura/main_extractor.py @@ -440,8 +440,11 @@ def handle_table(table_elem: _Element, potential_tags: Set[str], options: Extrac return None -def handle_image(element: _Element) -> Optional[_Element]: +def handle_image(element: Optional[_Element]) -> Optional[_Element]: "Process image elements and their relevant attributes." + if element is None: + return None + processed_element = Element(element.tag) for attr in ("data-src", "src"):