🕷️ 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
feat: add `length` property to `Selectors` to write less code
Karim shoair715dfb4243e1
diff --git a/scrapling/parser.py b/scrapling/parser.pyindex edc41f6..daddc9d 100644--- a/scrapling/parser.py+++ b/scrapling/parser.py@@ -1377,6 +1377,11 @@ class Selectors(List[Selector]):"""Returns the last item of the current list or `None` if the list is empty"""return self[-1] if len(self) > 0 else None+ @property+ def length(self):+ """Returns the length of the current list"""+ return len(self)+def __getstate__(self) -> Any:# lxml don't like it :)raise TypeError("Can't pickle Selectors object")