🕷️ 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
Fixing `re_first` logic in `Adaptors` type
Karim shoair009c2914aa32
diff --git a/scrapling/parser.py b/scrapling/parser.pyindex 2d0ebf1..3416ec6 100644--- a/scrapling/parser.py+++ b/scrapling/parser.py@@ -867,17 +867,18 @@ class Adaptors(List[Adaptor]):def re_first(self, regex: Union[str, Pattern[str]], default=None, replace_entities: bool = True):"""Call the ``.re_first()`` method for each element in this list and return- their results flattened as List of TextHandler.+ the first result or the default value otherwise.:param regex: Can be either a compiled regular expression or a string.:param default: The default value to be returned if there is no match:param replace_entities: if enabled character entity references are replaced by their corresponding character"""- results = [- n.text.re_first(regex, default, replace_entities) for n in self- ]- return flatten(results)+ for n in self:+ result = n.re_first(regex, None, replace_entities)+ if result:+ return result+ return default# def __getattr__(self, name):# if name in dir(self.__class__):