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

fix(parser): fix traverse selectors

Karim shoaira6fd25f64c3a
diff --git a/scrapling/parser.py b/scrapling/parser.py
index d3ec663..eac0d64 100644
--- a/scrapling/parser.py
+++ b/scrapling/parser.py
@@ -897,7 +897,7 @@ class Adaptor(SelectorsGeneration):
text = text.lower()
# This selector gets all elements with text content
- for node in self.__handle_elements(self._root.xpath('//*[normalize-space(text())]')):
+ for node in self.__handle_elements(self._root.xpath('.//*[normalize-space(text())]')):
"""Check if element matches given text otherwise, traverse the children tree and iterate"""
node_text = node.text
if clean_match:
@@ -933,7 +933,7 @@ class Adaptor(SelectorsGeneration):
results = Adaptors([])
# This selector gets all elements with text content
- for node in self.__handle_elements(self._root.xpath('//*[normalize-space(text())]')):
+ for node in self.__handle_elements(self._root.xpath('.//*[normalize-space(text())]')):
"""Check if element matches given regex otherwise, traverse the children tree and iterate"""
node_text = node.text
if node_text.re(query, check_match=True, clean_match=clean_match, case_sensitive=case_sensitive):