From 37607b7a04c65445d9345f79814bd7c8626236e4 Mon Sep 17 00:00:00 2001 From: CodyInnowhere Date: Wed, 18 Dec 2024 20:04:07 +0800 Subject: [PATCH] improve is_in_table_cell check --- trafilatura/utils.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/trafilatura/utils.py b/trafilatura/utils.py index 83bcbe90..2bf7efa7 100644 --- a/trafilatura/utils.py +++ b/trafilatura/utils.py @@ -464,11 +464,4 @@ def copy_attributes(dest_elem: _Element, src_elem: _Element) -> None: def is_in_table_cell(elem: _Element) -> bool: '''Check whether an element is in a table cell''' - while elem is not None: - if elem.tag == 'cell': - return True - parent = elem.getparent() - if parent is None: - break - elem = parent - return False + return elem.xpath('//ancestor::cell')