Skip to content

Commit c262efd

Browse files
committed
fix
1 parent a4c94ef commit c262efd

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/crawlee/crawlers/_adaptive_playwright/_adaptive_playwright_crawling_context.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ async def from_playwright_crawling_context(
188188
context_kwargs['_page'] = context_kwargs.pop('page')
189189
context_kwargs['_infinite_scroll'] = context_kwargs.pop('infinite_scroll')
190190
# This might not be always available.
191-
protocol_guess = await context_kwargs['_page'].evaluate('() => performance.getEntries()[0].nextHopProtocol')
191+
protocol_guess = await context_kwargs['_page'].evaluate('() => performance.getEntries()[0]?.nextHopProtocol')
192192
http_response = await PlaywrightHttpResponse.from_playwright_response(
193193
response=context.response, protocol=protocol_guess or ''
194194
)
@@ -295,7 +295,9 @@ async def from_post_navigation_context(
295295
context_kwargs.pop('goto_options', None)
296296

297297
if isinstance(context, PlaywrightPostNavCrawlingContext):
298-
protocol_guess = await context_kwargs['_page'].evaluate('() => performance.getEntries()[0].nextHopProtocol')
298+
protocol_guess = await context_kwargs['_page'].evaluate(
299+
'() => performance.getEntries()[0]?.nextHopProtocol'
300+
)
299301
context_kwargs['http_response'] = await PlaywrightHttpResponse.from_playwright_response(
300302
response=context.response, protocol=protocol_guess or ''
301303
)

0 commit comments

Comments
 (0)