Skip to content

Commit 0e1f3b9

Browse files
committed
fix(fetchers): Add backward compatibility for custom_config argument
1 parent 9b3309f commit 0e1f3b9

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

scrapling/fetchers/chrome.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ def fetch(cls, url: str, **kwargs: Unpack[PlaywrightSession]) -> Response:
5252
- additional_args: Additional arguments to be passed to Playwright's context as additional settings.
5353
:return: A `Response` object.
5454
"""
55-
# Get selector_config from kwargs if provided, otherwise use empty dict
56-
selector_config = kwargs.get("selector_config", {})
55+
selector_config = kwargs.get("selector_config", {}) or kwargs.get(
56+
"custom_config", {}
57+
) # Checking `custom_config` for backward compatibility
5758
if not isinstance(selector_config, dict):
5859
raise TypeError("Argument `selector_config` must be a dictionary.")
5960

60-
# Merge selector_config with class defaults
6161
kwargs["selector_config"] = {**cls._generate_parser_arguments(), **selector_config}
6262

6363
with DynamicSession(**kwargs) as session:
@@ -95,12 +95,12 @@ async def async_fetch(cls, url: str, **kwargs: Unpack[PlaywrightSession]) -> Res
9595
- additional_args: Additional arguments to be passed to Playwright's context as additional settings.
9696
:return: A `Response` object.
9797
"""
98-
# Get selector_config from kwargs if provided, otherwise use empty dict
99-
selector_config = kwargs.get("selector_config", {})
98+
selector_config = kwargs.get("selector_config", {}) or kwargs.get(
99+
"custom_config", {}
100+
) # Checking `custom_config` for backward compatibility
100101
if not isinstance(selector_config, dict):
101102
raise TypeError("Argument `selector_config` must be a dictionary.")
102103

103-
# Merge selector_config with class defaults
104104
kwargs["selector_config"] = {**cls._generate_parser_arguments(), **selector_config}
105105

106106
async with AsyncDynamicSession(**kwargs) as session:

scrapling/fetchers/firefox.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ def fetch(cls, url: str, **kwargs: Unpack[CamoufoxSession]) -> Response:
4545
- additional_args: Additional arguments to be passed to Camoufox as additional settings.
4646
:return: A `Response` object.
4747
"""
48-
# Get selector_config from kwargs if provided, otherwise use empty dict
49-
selector_config = kwargs.get("selector_config", {})
48+
selector_config = kwargs.get("selector_config", {}) or kwargs.get(
49+
"custom_config", {}
50+
) # Checking `custom_config` for backward compatibility
5051
if not isinstance(selector_config, dict):
5152
raise TypeError("Argument `selector_config` must be a dictionary.")
5253

53-
# Merge selector_config with class defaults
5454
kwargs["selector_config"] = {**cls._generate_parser_arguments(), **selector_config}
5555

5656
with StealthySession(**kwargs) as engine:
@@ -90,12 +90,12 @@ async def async_fetch(cls, url: str, **kwargs: Unpack[CamoufoxSession]) -> Respo
9090
- additional_args: Additional arguments to be passed to Camoufox as additional settings.
9191
:return: A `Response` object.
9292
"""
93-
# Get selector_config from kwargs if provided, otherwise use empty dict
94-
selector_config = kwargs.get("selector_config", {})
93+
selector_config = kwargs.get("selector_config", {}) or kwargs.get(
94+
"custom_config", {}
95+
) # Checking `custom_config` for backward compatibility
9596
if not isinstance(selector_config, dict):
9697
raise TypeError("Argument `selector_config` must be a dictionary.")
9798

98-
# Merge selector_config with class defaults
9999
kwargs["selector_config"] = {**cls._generate_parser_arguments(), **selector_config}
100100

101101
async with AsyncStealthySession(**kwargs) as engine:

0 commit comments

Comments
 (0)