3535from ._playwright_crawling_context import PlaywrightCrawlingContext
3636from ._playwright_http_client import PlaywrightHttpClient , browser_page_context
3737from ._playwright_pre_nav_crawling_context import PlaywrightPreNavCrawlingContext
38+ from ._types import GotoOptions
3839from ._utils import block_requests , infinite_scroll
3940
4041TCrawlingContext = TypeVar ('TCrawlingContext' , bound = PlaywrightCrawlingContext )
@@ -108,6 +109,7 @@ def __init__(
108109 user_data_dir : str | Path | None = None ,
109110 browser_launch_options : Mapping [str , Any ] | None = None ,
110111 browser_new_context_options : Mapping [str , Any ] | None = None ,
112+ goto_options : GotoOptions | None = None ,
111113 fingerprint_generator : FingerprintGenerator | None | Literal ['default' ] = 'default' ,
112114 headless : bool | None = None ,
113115 use_incognito_pages : bool | None = None ,
@@ -142,6 +144,8 @@ def __init__(
142144 This option should not be used if `browser_pool` is provided.
143145 navigation_timeout: Timeout for navigation (the process between opening a Playwright page and calling
144146 the request handler)
147+ goto_options: Additional options to pass to Playwright's `Page.goto()` method. Don't support `timeout`,
148+ use `navigation_timeout` instead.
145149 kwargs: Additional keyword arguments to pass to the underlying `BasicCrawler`.
146150 """
147151 configuration = kwargs .pop ('configuration' , None )
@@ -213,6 +217,7 @@ def __init__(
213217 kwargs ['concurrency_settings' ] = ConcurrencySettings (desired_concurrency = 1 )
214218
215219 self ._navigation_timeout = navigation_timeout or timedelta (minutes = 1 )
220+ self ._goto_options = goto_options or GotoOptions ()
216221
217222 super ().__init__ (** kwargs )
218223
@@ -238,6 +243,7 @@ async def _open_page(
238243 log = context .log ,
239244 page = crawlee_page .page ,
240245 block_requests = partial (block_requests , page = crawlee_page .page ),
246+ goto_options = GotoOptions (** self ._goto_options ),
241247 )
242248
243249 context_id = id (pre_navigation_context )
@@ -321,7 +327,7 @@ async def _navigate(
321327 try :
322328 async with self ._shared_navigation_timeouts [id (context )] as remaining_timeout :
323329 response = await context .page .goto (
324- context .request .url , timeout = remaining_timeout .total_seconds () * 1000
330+ context .request .url , timeout = remaining_timeout .total_seconds () * 1000 , ** context . goto_options
325331 )
326332 except playwright .async_api .TimeoutError as exc :
327333 raise asyncio .TimeoutError from exc
@@ -351,6 +357,7 @@ async def _navigate(
351357 extract_links = extract_links ,
352358 enqueue_links = self ._create_enqueue_links_function (context , extract_links ),
353359 block_requests = partial (block_requests , page = context .page ),
360+ goto_options = context .goto_options ,
354361 )
355362
356363 if context .session :
0 commit comments