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(StealthyFetcher): Improve OS name extraction

Karim shoair6e837f6a12d8
diff --git a/scrapling/engines/toolbelt/fingerprints.py b/scrapling/engines/toolbelt/fingerprints.py
index 9014397..186e4f3 100644
--- a/scrapling/engines/toolbelt/fingerprints.py
+++ b/scrapling/engines/toolbelt/fingerprints.py
@@ -2,7 +2,7 @@
Functions related to generating headers and fingerprints generally
"""
-import platform
+from platform import system as platform_system
from browserforge.fingerprints import Fingerprint, FingerprintGenerator
from browserforge.headers import Browser, HeaderGenerator
@@ -11,6 +11,8 @@ from tldextract import extract
from scrapling.core._types import Dict, Union
from scrapling.core.utils import lru_cache
+__OS_NAME__ = platform_system()
+
@lru_cache(10, typed=True)
def generate_convincing_referer(url: str) -> str:
@@ -32,15 +34,13 @@ def get_os_name() -> Union[str, None]:
:return: Current OS name or `None` otherwise
"""
- #
- os_name = platform.system()
return {
"Linux": "linux",
"Darwin": "macos",
"Windows": "windows",
# For the future? because why not?
"iOS": "ios",
- }.get(os_name)
+ }.get(__OS_NAME__)
def generate_suitable_fingerprint() -> Fingerprint: