From 55b708976663c91c28a3c5c080f766f9a041b5b2 Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Mon, 12 Aug 2024 09:51:01 -0700 Subject: [PATCH] fix: Handle UnboundLocalError in scrape_with_playwright --- aider/scrape.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/aider/scrape.py b/aider/scrape.py index ccd98b80e..0ffd12118 100755 --- a/aider/scrape.py +++ b/aider/scrape.py @@ -133,6 +133,7 @@ class Scraper: page.set_extra_http_headers({"User-Agent": user_agent}) + response = None try: response = page.goto(url, wait_until="networkidle", timeout=5000) except playwright._impl._errors.TimeoutError: @@ -143,7 +144,7 @@ class Scraper: try: content = page.content() - mime_type = response.header_value("content-type").split(";")[0] + mime_type = response.header_value("content-type").split(";")[0] if response else None except playwright._impl._errors.Error as e: self.print_error(f"Error retrieving page content: {str(e)}") content = None