From 4c74d9bc972cfce3b5eb46f92593b95b3b4ea095 Mon Sep 17 00:00:00 2001 From: Karim shoair Date: Wed, 20 Nov 2024 12:33:54 +0200 Subject: [PATCH] Fixing a bug with reading response bytes in playwright/camoufox when `network_idle` is used PlayWright doesn't provide a way to get the response in bytes after all wait ends like `page.content()` so that's more efficient to do anyway --- scrapling/engines/camo.py | 2 +- scrapling/engines/pw.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scrapling/engines/camo.py b/scrapling/engines/camo.py index 62fdd39..2f8a1f9 100644 --- a/scrapling/engines/camo.py +++ b/scrapling/engines/camo.py @@ -114,7 +114,7 @@ def fetch(self, url: str) -> Response: response = Response( url=res.url, text=page.content(), - body=res.body(), + body=page.content().encode('utf-8'), status=res.status, reason=res.status_text, encoding=encoding, diff --git a/scrapling/engines/pw.py b/scrapling/engines/pw.py index 3395ece..c83bfe3 100644 --- a/scrapling/engines/pw.py +++ b/scrapling/engines/pw.py @@ -224,7 +224,7 @@ def fetch(self, url: str) -> Response: response = Response( url=res.url, text=page.content(), - body=res.body(), + body=page.content().encode('utf-8'), status=res.status, reason=res.status_text, encoding=encoding,