mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-29 16:54:59 +00:00
fix: Handle UnboundLocalError in scrape_with_playwright
This commit is contained in:
parent
8d59ce586c
commit
55b7089766
1 changed files with 2 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue