@@ -204,8 +204,11 @@ def fetch(self, url: str, **kwargs: Unpack[StealthFetchParams]) -> Response:
204204 :param load_dom: Enabled by default, wait for all JavaScript on page(s) to fully load and execute.
205205 :param solve_cloudflare: Solves all types of the Cloudflare's Turnstile/Interstitial challenges before returning the response to you.
206206 :param selector_config: The arguments that will be passed in the end while creating the final Selector's class.
207+ :param proxy: Static proxy to override rotator and session proxy. A new browser context will be created and used with it.
207208 :return: A `Response` object.
208209 """
210+ static_proxy = kwargs .pop ("proxy" , None )
211+
209212 params = _validate (kwargs , self , StealthConfig )
210213 if not self ._is_alive : # pragma: no cover
211214 raise RuntimeError ("Context manager has been closed" )
@@ -218,7 +221,10 @@ def fetch(self, url: str, **kwargs: Unpack[StealthFetchParams]) -> Response:
218221 )
219222
220223 for attempt in range (self ._config .retries ):
221- proxy = self ._config .proxy_rotator .get_proxy () if self ._config .proxy_rotator else None
224+ if self ._config .proxy_rotator and static_proxy is None :
225+ proxy = self ._config .proxy_rotator .get_proxy ()
226+ else :
227+ proxy = static_proxy
222228
223229 with self ._page_generator (
224230 params .timeout , params .extra_headers , params .disable_resources , proxy
@@ -256,7 +262,7 @@ def fetch(self, url: str, **kwargs: Unpack[StealthFetchParams]) -> Response:
256262 page .wait_for_timeout (params .wait )
257263
258264 response = ResponseFactory .from_playwright_response (
259- page , first_response , final_response [0 ], params .selector_config
265+ page , first_response , final_response [0 ], params .selector_config , meta = { "proxy" : proxy }
260266 )
261267 return response
262268
@@ -454,8 +460,11 @@ async def fetch(self, url: str, **kwargs: Unpack[StealthFetchParams]) -> Respons
454460 :param load_dom: Enabled by default, wait for all JavaScript on page(s) to fully load and execute.
455461 :param solve_cloudflare: Solves all types of the Cloudflare's Turnstile/Interstitial challenges before returning the response to you.
456462 :param selector_config: The arguments that will be passed in the end while creating the final Selector's class.
463+ :param proxy: Static proxy to override rotator and session proxy. A new browser context will be created and used with it.
457464 :return: A `Response` object.
458465 """
466+ static_proxy = kwargs .pop ("proxy" , None )
467+
459468 params = _validate (kwargs , self , StealthConfig )
460469
461470 if not self ._is_alive : # pragma: no cover
@@ -469,7 +478,10 @@ async def fetch(self, url: str, **kwargs: Unpack[StealthFetchParams]) -> Respons
469478 )
470479
471480 for attempt in range (self ._config .retries ):
472- proxy = self ._config .proxy_rotator .get_proxy () if self ._config .proxy_rotator else None
481+ if self ._config .proxy_rotator and static_proxy is None :
482+ proxy = self ._config .proxy_rotator .get_proxy ()
483+ else :
484+ proxy = static_proxy
473485
474486 async with self ._page_generator (
475487 params .timeout , params .extra_headers , params .disable_resources , proxy
@@ -507,7 +519,7 @@ async def fetch(self, url: str, **kwargs: Unpack[StealthFetchParams]) -> Respons
507519 await page .wait_for_timeout (params .wait )
508520
509521 response = await ResponseFactory .from_async_playwright_response (
510- page , first_response , final_response [0 ], params .selector_config
522+ page , first_response , final_response [0 ], params .selector_config , meta = { "proxy" : proxy }
511523 )
512524 return response
513525
0 commit comments