Skip to content
Merged
Changes from 1 commit
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
6 changes: 5 additions & 1 deletion src/crawlee/crawlers/_playwright/_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
from dataclasses import dataclass
from typing import TYPE_CHECKING, Literal, Protocol, TypedDict

from playwright.async_api import APIResponse, Response
Comment thread
kozlice marked this conversation as resolved.
Outdated

from crawlee import HttpHeaders
from crawlee._utils.docs import docs_group

if TYPE_CHECKING:
from collections.abc import AsyncGenerator

from playwright.async_api import APIResponse, Response
from typing_extensions import NotRequired, Self


Expand Down Expand Up @@ -56,6 +57,9 @@ async def from_playwright_response(cls, response: Response | APIResponse, protoc
# Used http protocol version cannot be obtained from `Response` and has to be passed as additional argument.
http_version = protocol
_content = await response.body()
# If not called then the body will stay in memory until the context closes.
if isinstance(response, APIResponse):
await response.dispose()

return cls(http_version=http_version, status_code=status_code, headers=headers, _content=_content)

Expand Down
Loading