From 0e1f3b9b05958d7b3b7340c2acb19ce52a092a22 Mon Sep 17 00:00:00 2001 From: Karim shoair Date: Wed, 26 Nov 2025 02:23:17 +0200 Subject: [PATCH] fix(fetchers): Add backward compatibility for `custom_config` argument --- scrapling/fetchers/chrome.py | 12 ++++++------ scrapling/fetchers/firefox.py | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/scrapling/fetchers/chrome.py b/scrapling/fetchers/chrome.py index 44e7a44..a706826 100644 --- a/scrapling/fetchers/chrome.py +++ b/scrapling/fetchers/chrome.py @@ -52,12 +52,12 @@ class DynamicFetcher(BaseFetcher): - additional_args: Additional arguments to be passed to Playwright's context as additional settings. :return: A `Response` object. """ - # Get selector_config from kwargs if provided, otherwise use empty dict - selector_config = kwargs.get("selector_config", {}) + selector_config = kwargs.get("selector_config", {}) or kwargs.get( + "custom_config", {} + ) # Checking `custom_config` for backward compatibility if not isinstance(selector_config, dict): raise TypeError("Argument `selector_config` must be a dictionary.") - # Merge selector_config with class defaults kwargs["selector_config"] = {**cls._generate_parser_arguments(), **selector_config} with DynamicSession(**kwargs) as session: @@ -95,12 +95,12 @@ class DynamicFetcher(BaseFetcher): - additional_args: Additional arguments to be passed to Playwright's context as additional settings. :return: A `Response` object. """ - # Get selector_config from kwargs if provided, otherwise use empty dict - selector_config = kwargs.get("selector_config", {}) + selector_config = kwargs.get("selector_config", {}) or kwargs.get( + "custom_config", {} + ) # Checking `custom_config` for backward compatibility if not isinstance(selector_config, dict): raise TypeError("Argument `selector_config` must be a dictionary.") - # Merge selector_config with class defaults kwargs["selector_config"] = {**cls._generate_parser_arguments(), **selector_config} async with AsyncDynamicSession(**kwargs) as session: diff --git a/scrapling/fetchers/firefox.py b/scrapling/fetchers/firefox.py index 825b917..a9361d6 100644 --- a/scrapling/fetchers/firefox.py +++ b/scrapling/fetchers/firefox.py @@ -45,12 +45,12 @@ class StealthyFetcher(BaseFetcher): - additional_args: Additional arguments to be passed to Camoufox as additional settings. :return: A `Response` object. """ - # Get selector_config from kwargs if provided, otherwise use empty dict - selector_config = kwargs.get("selector_config", {}) + selector_config = kwargs.get("selector_config", {}) or kwargs.get( + "custom_config", {} + ) # Checking `custom_config` for backward compatibility if not isinstance(selector_config, dict): raise TypeError("Argument `selector_config` must be a dictionary.") - # Merge selector_config with class defaults kwargs["selector_config"] = {**cls._generate_parser_arguments(), **selector_config} with StealthySession(**kwargs) as engine: @@ -90,12 +90,12 @@ class StealthyFetcher(BaseFetcher): - additional_args: Additional arguments to be passed to Camoufox as additional settings. :return: A `Response` object. """ - # Get selector_config from kwargs if provided, otherwise use empty dict - selector_config = kwargs.get("selector_config", {}) + selector_config = kwargs.get("selector_config", {}) or kwargs.get( + "custom_config", {} + ) # Checking `custom_config` for backward compatibility if not isinstance(selector_config, dict): raise TypeError("Argument `selector_config` must be a dictionary.") - # Merge selector_config with class defaults kwargs["selector_config"] = {**cls._generate_parser_arguments(), **selector_config} async with AsyncStealthySession(**kwargs) as engine: