Karim shoair commited on
Commit
335667a
·
1 Parent(s): 4c54bbe

fix(parser): An encoding issue with converting bytes to string on some encoding types

Browse files
Files changed (1) hide show
  1. scrapling/parser.py +2 -2
scrapling/parser.py CHANGED
@@ -341,7 +341,7 @@ class Selector(SelectorsGeneration):
341
  """Return the inner HTML code of the element"""
342
  content = tostring(self._root, encoding=self.encoding, method="html", with_tail=False)
343
  if isinstance(content, bytes):
344
- content = content.decode("utf-8")
345
  return TextHandler(content)
346
 
347
  @property
@@ -359,7 +359,7 @@ class Selector(SelectorsGeneration):
359
  with_tail=False,
360
  )
361
  if isinstance(content, bytes):
362
- content = content.decode("utf-8")
363
  return TextHandler(content)
364
 
365
  def has_class(self, class_name: str) -> bool:
 
341
  """Return the inner HTML code of the element"""
342
  content = tostring(self._root, encoding=self.encoding, method="html", with_tail=False)
343
  if isinstance(content, bytes):
344
+ content = content.strip().decode(self.encoding)
345
  return TextHandler(content)
346
 
347
  @property
 
359
  with_tail=False,
360
  )
361
  if isinstance(content, bytes):
362
+ content = content.strip().decode(self.encoding)
363
  return TextHandler(content)
364
 
365
  def has_class(self, class_name: str) -> bool: