Skip to content

🕷️ 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

fix(fetcher): Replace vars logic with one that doesn't require dict attribute

Karim shoair74f24d60f6a2
diff --git a/scrapling/engines/static.py b/scrapling/engines/static.py
index 796df13..a442002 100644
--- a/scrapling/engines/static.py
+++ b/scrapling/engines/static.py
@@ -647,7 +647,7 @@ class FetcherSession:
"""Creates and returns a new synchronous Fetcher Session"""
if self._client is None:
# Use **vars(self) to avoid repeating all parameters
- config = {k.replace("_default_", ""): v for k, v in vars(self).items() if k.startswith("_default")}
+ config = {k.replace("_default_", ""): getattr(self, k) for k in self.__slots__ if k.startswith("_default")}
config["stealthy_headers"] = self._stealth
config["selector_config"] = self.selector_config
self._client = _SyncSessionLogic(**config)
@@ -665,7 +665,7 @@ class FetcherSession:
"""Creates and returns a new asynchronous Session."""
if self._client is None:
# Use **vars(self) to avoid repeating all parameters
- config = {k.replace("_default_", ""): v for k, v in vars(self).items() if k.startswith("_default")}
+ config = {k.replace("_default_", ""): getattr(self, k) for k in self.__slots__ if k.startswith("_default")}
config["stealthy_headers"] = self._stealth
config["selector_config"] = self.selector_config
self._client = _ASyncSessionLogic(**config)