Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/crawlee/browsers/_browser_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,10 @@ async def close_with_hooks(*args: Any, **kwargs: Any) -> None:
await original_close(*args, **kwargs)
await self._execute_hooks(self._post_page_close_hooks, crawlee_page.id, browser_controller)

crawlee_page.page.close: Callable[..., Awaitable[None]] = close_with_hooks
# `Page.close` is a regular method, so type checkers reject reassigning it directly.
# Install the hook-wrapped version through an untyped reference to the page.
page: Any = crawlee_page.page
page.close = close_with_hooks

def pre_launch_hook(
self, hook: Callable[[str, BrowserPlugin], Awaitable[None]]
Expand Down
39 changes: 21 additions & 18 deletions src/crawlee/crawlers/_playwright/_playwright_crawler.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,24 +303,27 @@ def _build_crawling_context(
"""Build the final crawling context by adding Playwright-specific helper methods."""
extract_links = self._create_extract_links_function(context)

return self._CRAWLING_CONTEXT_CLASS(
request=context.request,
session=context.session,
add_requests=context.add_requests,
send_request=context.send_request,
push_data=context.push_data,
use_state=context.use_state,
proxy_info=context.proxy_info,
get_key_value_store=context.get_key_value_store,
log=context.log,
register_deferred_cleanup=context.register_deferred_cleanup,
page=context.page,
goto_options=context.goto_options,
response=context.response,
infinite_scroll=lambda: infinite_scroll(context.page),
extract_links=extract_links,
enqueue_links=self._create_enqueue_links_function(context, extract_links),
block_requests=context.block_requests,
return cast(
'TCrawlingContext',
self._CRAWLING_CONTEXT_CLASS(
request=context.request,
session=context.session,
add_requests=context.add_requests,
send_request=context.send_request,
push_data=context.push_data,
use_state=context.use_state,
proxy_info=context.proxy_info,
get_key_value_store=context.get_key_value_store,
log=context.log,
register_deferred_cleanup=context.register_deferred_cleanup,
page=context.page,
goto_options=context.goto_options,
response=context.response,
infinite_scroll=lambda: infinite_scroll(context.page),
extract_links=extract_links,
enqueue_links=self._create_enqueue_links_function(context, extract_links),
block_requests=context.block_requests,
),
)

async def _open_page(
Expand Down
4 changes: 2 additions & 2 deletions src/crawlee/storage_clients/_redis/_dataset_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,14 +191,14 @@ async def get_data(
json_path += f'[:-{offset}]'
case (True, int(), int()):
# ty lacks support for advanced pattern matching, see https://github.com/astral-sh/ty/issues/887.
json_path += f'[-{offset + limit}:-{offset}]' # ty: ignore[unsupported-operator]
json_path += f'[-{offset + limit}:-{offset}]'
case (False, 0, int()):
json_path += f'[:{limit}]'
case (False, int(), None):
json_path += f'[{offset}:]'
case (False, int(), int()):
# ty lacks support for advanced pattern matching, see https://github.com/astral-sh/ty/issues/887.
json_path += f'[{offset}:{offset + limit}]' # ty: ignore[unsupported-operator]
json_path += f'[{offset}:{offset + limit}]'

if json_path == '$':
json_path = '$[*]'
Expand Down
42 changes: 21 additions & 21 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading