🕷️ The BEST Web Scraping framework that handles everything from a single request to a full-scale crawl! Don't be shy, join here: https://discord.gg/EMgGbDceNQ and follow here for daily tips and tricks: https://x.com/Scrapling_dev
Python aiai-scrapingautomationcrawlercrawlingcrawling-pythondatadata-extractionmcpmcp-serverplaywrightpythonscrapingselectorsstealthweb-scraperweb-scrapingweb-scraping-pythonwebscrapingxpath
fix(parser): Improve response to json conversion
Karim shoairae719a9d543c
diff --git a/scrapling/parser.py b/scrapling/parser.pyindex 95b88ee..f7da3a9 100644--- a/scrapling/parser.py+++ b/scrapling/parser.py@@ -939,8 +939,13 @@ class Selector(SelectorsGeneration):# Operations on text functionsdef json(self) -> Dict:"""Return JSON response if the response is jsonable otherwise throws error"""- if self._raw_body and isinstance(self._raw_body, str):- return TextHandler(self._raw_body).json()+ if self._raw_body and isinstance(self._raw_body, (str, bytes)):+ if isinstance(self._raw_body, str):+ return TextHandler(self._raw_body).json()+ else:+ if TYPE_CHECKING:+ assert isinstance(self._raw_body, bytes)+ return TextHandler(self._raw_body.decode()).json()elif self.text:return self.text.json()else: