perf: optimize get_all_text and adaptive logic by another 10%
This commit is contained in:
+2
-2
@@ -323,7 +323,7 @@ class Selector(SelectorsGeneration):
|
|||||||
ignored_elements.update(set(element.iterchildren()))
|
ignored_elements.update(set(element.iterchildren()))
|
||||||
|
|
||||||
_all_strings = []
|
_all_strings = []
|
||||||
for node in self._root.xpath(".//*"):
|
for node in self._root.iter():
|
||||||
if node not in ignored_elements:
|
if node not in ignored_elements:
|
||||||
text = node.text
|
text = node.text
|
||||||
if text and isinstance(text, str):
|
if text and isinstance(text, str):
|
||||||
@@ -496,7 +496,7 @@ class Selector(SelectorsGeneration):
|
|||||||
if issubclass(type(element), HtmlElement):
|
if issubclass(type(element), HtmlElement):
|
||||||
element = _StorageTools.element_to_dict(element)
|
element = _StorageTools.element_to_dict(element)
|
||||||
|
|
||||||
for node in self._root.xpath(".//*"):
|
for node in self._root.iter("*"):
|
||||||
# Collect all elements in the page, then for each element get the matching score of it against the node.
|
# Collect all elements in the page, then for each element get the matching score of it against the node.
|
||||||
# Hence: the code doesn't stop even if the score was 100%
|
# Hence: the code doesn't stop even if the score was 100%
|
||||||
# because there might be another element(s) left in page with the same score
|
# because there might be another element(s) left in page with the same score
|
||||||
|
|||||||
Reference in New Issue
Block a user