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

refactor: remove clean up function for Adaptor + make adaptor attributes accessible directly

Karim shoaira5e4b91653a5
diff --git a/scrapling/parser.py b/scrapling/parser.py
index 3ff3f2c..0371c99 100644
--- a/scrapling/parser.py
+++ b/scrapling/parser.py
@@ -185,15 +185,11 @@ class Adaptor(SelectorsGeneration):
else {}
)
- def __del__(self):
- """Ensure cleanup happens"""
- if hasattr(self, "_storage") and self._storage:
- try:
- self._storage.close()
- except Exception:
- pass
- finally:
- self._storage = None
+ def __getitem__(self, key: str) -> TextHandler:
+ return self.attrib[key]
+
+ def __contains__(self, key: str) -> bool:
+ return key in self.attrib
# Node functionalities, I wanted to move to a separate Mixin class, but it had a slight impact on performance
@staticmethod