Spaces:
Sleeping
Sleeping
NIG
Browse files
app.py
CHANGED
|
@@ -270,19 +270,39 @@ def seek():
|
|
| 270 |
options.add_argument("--disable-dev-shm-usage")
|
| 271 |
options.add_argument("--remote-debugging-port=9222")
|
| 272 |
|
| 273 |
-
#
|
| 274 |
-
import os
|
| 275 |
-
original_cwd = os.getcwd()
|
| 276 |
-
os.chdir("/tmp")
|
| 277 |
-
|
| 278 |
try:
|
| 279 |
-
#
|
| 280 |
-
|
| 281 |
-
|
| 282 |
-
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 286 |
|
| 287 |
# Wait for the page to load and look for divp elements
|
| 288 |
try:
|
|
|
|
| 270 |
options.add_argument("--disable-dev-shm-usage")
|
| 271 |
options.add_argument("--remote-debugging-port=9222")
|
| 272 |
|
| 273 |
+
# Try to use Chrome directly without webdriver-manager
|
|
|
|
|
|
|
|
|
|
|
|
|
| 274 |
try:
|
| 275 |
+
# First try direct Chrome path
|
| 276 |
+
driver = webdriver.Chrome(options=options)
|
| 277 |
+
except:
|
| 278 |
+
try:
|
| 279 |
+
# Fallback to webdriver-manager with forced path
|
| 280 |
+
from webdriver_manager.core.os_manager import ChromeType
|
| 281 |
+
from webdriver_manager.chrome import ChromeDriverManager
|
| 282 |
+
|
| 283 |
+
# Force the cache path by monkey patching the default path
|
| 284 |
+
import webdriver_manager.core.download_manager
|
| 285 |
+
webdriver_manager.core.download_manager.DEFAULT_PATH = "/tmp/webdriver-manager"
|
| 286 |
+
|
| 287 |
+
service = Service(ChromeDriverManager().install())
|
| 288 |
+
driver = webdriver.Chrome(service=service, options=options)
|
| 289 |
+
except Exception as e:
|
| 290 |
+
print(f"ChromeDriver setup failed: {e}")
|
| 291 |
+
# Last resort: try to find ChromeDriver in common locations
|
| 292 |
+
import subprocess
|
| 293 |
+
try:
|
| 294 |
+
result = subprocess.run(['which', 'chromedriver'], capture_output=True, text=True)
|
| 295 |
+
if result.returncode == 0:
|
| 296 |
+
chromedriver_path = result.stdout.strip()
|
| 297 |
+
service = Service(chromedriver_path)
|
| 298 |
+
driver = webdriver.Chrome(service=service, options=options)
|
| 299 |
+
else:
|
| 300 |
+
raise Exception("ChromeDriver not found in PATH")
|
| 301 |
+
except Exception as e2:
|
| 302 |
+
print(f"All ChromeDriver attempts failed: {e2}")
|
| 303 |
+
raise
|
| 304 |
+
|
| 305 |
+
driver.get(url)
|
| 306 |
|
| 307 |
# Wait for the page to load and look for divp elements
|
| 308 |
try:
|