fix(fetchers): Add backward compatibility for custom_config argument
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user