mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-01 02:05:00 +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})
|
page.set_extra_http_headers({"User-Agent": user_agent})
|
||||||
|
|
||||||
|
response = None
|
||||||
try:
|
try:
|
||||||
response = page.goto(url, wait_until="networkidle", timeout=5000)
|
response = page.goto(url, wait_until="networkidle", timeout=5000)
|
||||||
except playwright._impl._errors.TimeoutError:
|
except playwright._impl._errors.TimeoutError:
|
||||||
|
@ -143,7 +144,7 @@ class Scraper:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
content = page.content()
|
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:
|
except playwright._impl._errors.Error as e:
|
||||||
self.print_error(f"Error retrieving page content: {str(e)}")
|
self.print_error(f"Error retrieving page content: {str(e)}")
|
||||||
content = None
|
content = None
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue