Handling an edge case and adding more commentary
This commit is contained in:
@@ -188,6 +188,7 @@ class Adaptor(SelectorsGeneration):
|
||||
"""Get text content of the element"""
|
||||
if not self.__text:
|
||||
if self.__keep_comments:
|
||||
if not self.children:
|
||||
# If use chose to keep comments, remove comments from text
|
||||
# Escape lxml default behaviour and remove comments like this `<span>CONDITION: <!-- -->Excellent</span>`
|
||||
# This issue is present in parsel/scrapy as well so no need to repeat it here so the user can run regex on the full text.
|
||||
@@ -200,6 +201,9 @@ class Adaptor(SelectorsGeneration):
|
||||
self.__text = TextHandler(fragment_root.text)
|
||||
else:
|
||||
self.__text = TextHandler(self._root.text)
|
||||
else:
|
||||
# If user already chose to not keep comments then all is good
|
||||
self.__text = TextHandler(self._root.text)
|
||||
return self.__text
|
||||
|
||||
def get_all_text(self, separator: str = "\n", strip: bool = False, ignore_tags: Tuple = ('script', 'style',), valid_values: bool = True) -> TextHandler:
|
||||
|
||||
Reference in New Issue
Block a user