Karim shoair commited on
Commit ·
5bdca2f
1
Parent(s): 2be9ad9
feat(parser): Make all returned html as TextHandler
Browse files- scrapling/parser.py +6 -6
scrapling/parser.py
CHANGED
|
@@ -259,18 +259,18 @@ class Adaptor(SelectorsGeneration):
|
|
| 259 |
return self.__attributes
|
| 260 |
|
| 261 |
@property
|
| 262 |
-
def html_content(self) ->
|
| 263 |
"""Return the inner html code of the element"""
|
| 264 |
-
return etree.tostring(self._root, encoding='unicode', method='html', with_tail=False)
|
| 265 |
|
| 266 |
@property
|
| 267 |
-
def body(self) ->
|
| 268 |
"""Return raw HTML code of the element/page without any processing when possible or return `Adaptor.html_content`"""
|
| 269 |
-
return self.__raw_body or self.html_content
|
| 270 |
|
| 271 |
-
def prettify(self) ->
|
| 272 |
"""Return a prettified version of the element's inner html-code"""
|
| 273 |
-
return etree.tostring(self._root, encoding='unicode', pretty_print=True, method='html', with_tail=False)
|
| 274 |
|
| 275 |
def has_class(self, class_name: str) -> bool:
|
| 276 |
"""Check if element has a specific class
|
|
|
|
| 259 |
return self.__attributes
|
| 260 |
|
| 261 |
@property
|
| 262 |
+
def html_content(self) -> TextHandler:
|
| 263 |
"""Return the inner html code of the element"""
|
| 264 |
+
return TextHandler(etree.tostring(self._root, encoding='unicode', method='html', with_tail=False))
|
| 265 |
|
| 266 |
@property
|
| 267 |
+
def body(self) -> TextHandler:
|
| 268 |
"""Return raw HTML code of the element/page without any processing when possible or return `Adaptor.html_content`"""
|
| 269 |
+
return TextHandler(self.__raw_body) or self.html_content
|
| 270 |
|
| 271 |
+
def prettify(self) -> TextHandler:
|
| 272 |
"""Return a prettified version of the element's inner html-code"""
|
| 273 |
+
return TextHandler(etree.tostring(self._root, encoding='unicode', pretty_print=True, method='html', with_tail=False))
|
| 274 |
|
| 275 |
def has_class(self, class_name: str) -> bool:
|
| 276 |
"""Check if element has a specific class
|