Create browser_controller.py
Browse files- browser_controller.py +2 -6
browser_controller.py
CHANGED
|
@@ -3,7 +3,6 @@ from playwright.sync_api import sync_playwright
|
|
| 3 |
class BrowserController:
|
| 4 |
def __init__(self):
|
| 5 |
self.playwright = sync_playwright().start()
|
| 6 |
-
# Headless=True for Hugging Face Spaces compatibility
|
| 7 |
self.browser = self.playwright.chromium.launch(headless=True)
|
| 8 |
self.page = self.browser.new_page()
|
| 9 |
|
|
@@ -24,12 +23,9 @@ class BrowserController:
|
|
| 24 |
return self.get_state()
|
| 25 |
|
| 26 |
def get_state(self):
|
| 27 |
-
# Screenshot as hex string, HTML as string
|
| 28 |
-
screenshot_bytes = self.page.screenshot()
|
| 29 |
-
html_content = self.page.content()
|
| 30 |
return {
|
| 31 |
-
"screenshot":
|
| 32 |
-
"html":
|
| 33 |
}
|
| 34 |
|
| 35 |
def close(self):
|
|
|
|
| 3 |
class BrowserController:
|
| 4 |
def __init__(self):
|
| 5 |
self.playwright = sync_playwright().start()
|
|
|
|
| 6 |
self.browser = self.playwright.chromium.launch(headless=True)
|
| 7 |
self.page = self.browser.new_page()
|
| 8 |
|
|
|
|
| 23 |
return self.get_state()
|
| 24 |
|
| 25 |
def get_state(self):
|
|
|
|
|
|
|
|
|
|
| 26 |
return {
|
| 27 |
+
"screenshot": self.page.screenshot().hex(),
|
| 28 |
+
"html": self.page.content()
|
| 29 |
}
|
| 30 |
|
| 31 |
def close(self):
|