Skip to content

🕷️ The BEST Web Scraping framework that handles everything from a single request to a full-scale crawl! Don't be shy, join here: https://discord.gg/EMgGbDceNQ and follow here for daily tips and tricks: https://x.com/Scrapling_dev

perf: speed up `get_all_text` function by another 20%

Karim shoair548a40d850c2
diff --git a/scrapling/parser.py b/scrapling/parser.py
index 457b0ff..e6a6af3 100644
--- a/scrapling/parser.py
+++ b/scrapling/parser.py
@@ -318,10 +318,9 @@ class Selector(SelectorsGeneration):
"""
ignored_elements = set()
if ignore_tags:
- for tag in ignore_tags:
- for element in self._root.xpath(f".//{tag}"):
- ignored_elements.add(element)
- ignored_elements.update(set(element.iterchildren()))
+ for element in self._root.iter(*ignore_tags):
+ ignored_elements.add(element)
+ ignored_elements.update(set(element.iterchildren()))
_all_strings = []
for node in self._root.xpath(".//*"):