Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -11,12 +11,9 @@ from PIL import Image
|
|
11 |
from io import BytesIO
|
12 |
|
13 |
from playwright.sync_api import sync_playwright
|
14 |
-
|
15 |
-
|
16 |
-
from selenium.webdriver.chrome.service import Service
|
17 |
-
from webdriver_manager.chrome import ChromeDriverManager
|
18 |
from selenium.webdriver.chrome.options import Options
|
19 |
|
|
|
20 |
HF_TOKEN = os.getenv("HF_TOKEN")
|
21 |
hf_client = InferenceClient("CohereForAI/c4ai-command-r-plus-08-2024", token=HF_TOKEN)
|
22 |
|
@@ -113,20 +110,19 @@ def on_select(space):
|
|
113 |
print(traceback.format_exc())
|
114 |
return f"์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค: {str(e)}", "", Image.new('RGB', (1, 1))
|
115 |
|
116 |
-
|
117 |
-
|
118 |
def take_screenshot(url):
|
119 |
try:
|
120 |
chrome_options = Options()
|
121 |
chrome_options.add_argument("--headless")
|
122 |
chrome_options.add_argument("--no-sandbox")
|
123 |
chrome_options.add_argument("--disable-dev-shm-usage")
|
|
|
|
|
124 |
|
125 |
-
|
126 |
-
driver = webdriver.Chrome(
|
127 |
|
128 |
driver.get(url)
|
129 |
-
driver.set_window_size(1080, 720)
|
130 |
screenshot = driver.get_screenshot_as_png()
|
131 |
driver.quit()
|
132 |
|
|
|
11 |
from io import BytesIO
|
12 |
|
13 |
from playwright.sync_api import sync_playwright
|
|
|
|
|
|
|
|
|
14 |
from selenium.webdriver.chrome.options import Options
|
15 |
|
16 |
+
|
17 |
HF_TOKEN = os.getenv("HF_TOKEN")
|
18 |
hf_client = InferenceClient("CohereForAI/c4ai-command-r-plus-08-2024", token=HF_TOKEN)
|
19 |
|
|
|
110 |
print(traceback.format_exc())
|
111 |
return f"์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค: {str(e)}", "", Image.new('RGB', (1, 1))
|
112 |
|
|
|
|
|
113 |
def take_screenshot(url):
|
114 |
try:
|
115 |
chrome_options = Options()
|
116 |
chrome_options.add_argument("--headless")
|
117 |
chrome_options.add_argument("--no-sandbox")
|
118 |
chrome_options.add_argument("--disable-dev-shm-usage")
|
119 |
+
chrome_options.add_argument("--disable-gpu")
|
120 |
+
chrome_options.add_argument("--window-size=1080,720")
|
121 |
|
122 |
+
# ์ปจํ
์ด๋ ํ๊ฒฝ์ ๋ง๋ ChromeDriver ๊ฒฝ๋ก ์ค์
|
123 |
+
driver = webdriver.Chrome(options=chrome_options)
|
124 |
|
125 |
driver.get(url)
|
|
|
126 |
screenshot = driver.get_screenshot_as_png()
|
127 |
driver.quit()
|
128 |
|