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: optimizing `find_similar` method

Karim shoair1ec6f0e0f011
diff --git a/scrapling/parser.py b/scrapling/parser.py
index 8146461..e3d30c6 100644
--- a/scrapling/parser.py
+++ b/scrapling/parser.py
@@ -1082,7 +1082,7 @@ class Selector(SelectorsGeneration):
"src",
),
match_text: bool = False,
- ) -> Union["Selectors", List]:
+ ) -> "Selectors":
"""Find elements that are in the same tree depth in the page with the same tag name and same parent tag etc...
then return the ones that match the current element attributes with a percentage higher than the input threshold.
@@ -1136,7 +1136,7 @@ class Selector(SelectorsGeneration):
):
similar_elements.append(potential_match)
- return self.__handle_elements(similar_elements)
+ return Selectors(map(self.__element_convertor, similar_elements))
def find_by_text(
self,