From 63a46a8e0bec5b2312427a61a14a434bc2799f1b Mon Sep 17 00:00:00 2001 From: Karim shoair Date: Tue, 23 Sep 2025 18:32:56 +0300 Subject: [PATCH] fix(parser): An encoding issue with converting bytes to string on some encoding types Removing that `invalid start byte` annoying bug --- scrapling/parser.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scrapling/parser.py b/scrapling/parser.py index f0b9e54..776dd55 100644 --- a/scrapling/parser.py +++ b/scrapling/parser.py @@ -341,7 +341,7 @@ class Selector(SelectorsGeneration): """Return the inner HTML code of the element""" content = tostring(self._root, encoding=self.encoding, method="html", with_tail=False) if isinstance(content, bytes): - content = content.decode("utf-8") + content = content.strip().decode(self.encoding) return TextHandler(content) @property @@ -359,7 +359,7 @@ class Selector(SelectorsGeneration): with_tail=False, ) if isinstance(content, bytes): - content = content.decode("utf-8") + content = content.strip().decode(self.encoding) return TextHandler(content) def has_class(self, class_name: str) -> bool: