Karim shoair commited on
Commit
e7eec4a
·
1 Parent(s): 32c7833

perf: optimizing `find_similar` method

Browse files
Files changed (1) hide show
  1. scrapling/parser.py +2 -2
scrapling/parser.py CHANGED
@@ -1082,7 +1082,7 @@ class Selector(SelectorsGeneration):
1082
  "src",
1083
  ),
1084
  match_text: bool = False,
1085
- ) -> Union["Selectors", List]:
1086
  """Find elements that are in the same tree depth in the page with the same tag name and same parent tag etc...
1087
  then return the ones that match the current element attributes with a percentage higher than the input threshold.
1088
 
@@ -1136,7 +1136,7 @@ class Selector(SelectorsGeneration):
1136
  ):
1137
  similar_elements.append(potential_match)
1138
 
1139
- return self.__handle_elements(similar_elements)
1140
 
1141
  def find_by_text(
1142
  self,
 
1082
  "src",
1083
  ),
1084
  match_text: bool = False,
1085
+ ) -> "Selectors":
1086
  """Find elements that are in the same tree depth in the page with the same tag name and same parent tag etc...
1087
  then return the ones that match the current element attributes with a percentage higher than the input threshold.
1088
 
 
1136
  ):
1137
  similar_elements.append(potential_match)
1138
 
1139
+ return Selectors(map(self.__element_convertor, similar_elements))
1140
 
1141
  def find_by_text(
1142
  self,