From d220050160d7c3280b3c79348c83eb6e5e37bfd7 Mon Sep 17 00:00:00 2001 From: Karim shoair Date: Mon, 28 Jul 2025 03:29:13 +0300 Subject: [PATCH] refactor(parser): Make `get_all_text` method 40% faster --- scrapling/parser.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scrapling/parser.py b/scrapling/parser.py index 941727d..ad83f26 100644 --- a/scrapling/parser.py +++ b/scrapling/parser.py @@ -304,7 +304,7 @@ class Adaptor(SelectorsGeneration): for tag in ignore_tags: for element in self._root.xpath(f".//{tag}"): ignored_elements.add(element) - ignored_elements.update(element.xpath(".//*")) + ignored_elements.update(set(element.iterchildren())) _all_strings = [] for node in self._root.xpath(".//*"): @@ -315,7 +315,7 @@ class Adaptor(SelectorsGeneration): if not valid_values or processed_text.strip(): _all_strings.append(processed_text) - return TextHandler(separator.join(_all_strings)) + return TextHandler(separator).join(_all_strings) def urljoin(self, relative_url: str) -> str: """Join this Adaptor's url with a relative url to form an absolute full URL."""