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(TextHandler): auto handling non-string type variables

Karim shoairbf6a3a9c2054
diff --git a/scrapling/core/custom_types.py b/scrapling/core/custom_types.py
index 67e4e00..6d09592 100644
--- a/scrapling/core/custom_types.py
+++ b/scrapling/core/custom_types.py
@@ -19,9 +19,7 @@ class TextHandler(str):
__slots__ = ()
def __new__(cls, string):
- if isinstance(string, str):
- return super().__new__(cls, string)
- return super().__new__(cls, '')
+ return super().__new__(cls, str(string))
def __getitem__(self, key: Union[SupportsIndex, slice]) -> "TextHandler":
lst = super().__getitem__(key)