42Cummer commited on
Commit
0800340
·
verified ·
1 Parent(s): 447604f
Files changed (2) hide show
  1. Dockerfile +22 -1
  2. app.py +8 -34
Dockerfile CHANGED
@@ -1,11 +1,32 @@
1
  FROM python:3.10-slim
2
 
3
- # Install basic dependencies
4
  RUN apt-get update && apt-get install -y \
5
  wget \
6
  gnupg \
7
  unzip \
8
  curl \
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  && apt-get clean \
10
  && rm -rf /var/lib/apt/lists/*
11
 
 
1
  FROM python:3.10-slim
2
 
3
+ # Install basic dependencies and Chrome runtime libraries
4
  RUN apt-get update && apt-get install -y \
5
  wget \
6
  gnupg \
7
  unzip \
8
  curl \
9
+ libglib2.0-0 \
10
+ libgobject-2.0-0 \
11
+ libnspr4 \
12
+ libnss3 \
13
+ libnssutil3 \
14
+ libdbus-1-3 \
15
+ libgio2.0-0 \
16
+ libatk1.0-0 \
17
+ libatk-bridge2.0-0 \
18
+ libexpat1 \
19
+ libatspi2.0-0 \
20
+ libx11-6 \
21
+ libxcomposite1 \
22
+ libxdamage1 \
23
+ libxext6 \
24
+ libxfixes3 \
25
+ libxrandr2 \
26
+ libgbm1 \
27
+ libxcb1 \
28
+ libxkbcommon0 \
29
+ libasound2 \
30
  && apt-get clean \
31
  && rm -rf /var/lib/apt/lists/*
32
 
app.py CHANGED
@@ -254,40 +254,14 @@ def seek():
254
  }
255
  # Use Playwright to handle redirects and wait for page to load
256
  with sync_playwright() as p:
257
- # Let Playwright find the browser automatically
258
- try:
259
- browser = p.chromium.launch(headless=True)
260
- except Exception as e:
261
- print(f"Failed to launch with default path: {e}")
262
- # Fallback: try to find the browser manually
263
- import os
264
- import glob
265
-
266
- # Check what's actually in the playwright-browsers directory
267
- if os.path.exists("/tmp/playwright-browsers"):
268
- print("Contents of /tmp/playwright-browsers:")
269
- os.system("find /tmp/playwright-browsers -type f -name 'chrome' -o -name 'chromium' -o -name 'headless_shell'")
270
-
271
- # Try different common paths
272
- possible_paths = [
273
- "/tmp/playwright-browsers/chromium-*/chrome-linux/chrome",
274
- "/tmp/playwright-browsers/chromium-*/chrome-linux/headless_shell",
275
- "/tmp/playwright-browsers/chromium-*/chrome-linux/chromium"
276
- ]
277
-
278
- for pattern in possible_paths:
279
- paths = glob.glob(pattern)
280
- if paths:
281
- print(f"Found executable with pattern {pattern}: {paths[0]}")
282
- try:
283
- browser = p.chromium.launch(headless=True, executable_path=paths[0])
284
- break
285
- except Exception as e2:
286
- print(f"Failed with {paths[0]}: {e2}")
287
- else:
288
- raise Exception("Could not find working Chrome executable")
289
- else:
290
- raise Exception("/tmp/playwright-browsers directory does not exist")
291
 
292
  page = browser.new_page()
293
  page.goto(url)
 
254
  }
255
  # Use Playwright to handle redirects and wait for page to load
256
  with sync_playwright() as p:
257
+ # Use the known working Chrome executable path
258
+ executable_path = "/tmp/playwright-browsers/chromium-1181/chrome-linux/chrome"
259
+ print(f"Using Chrome executable: {executable_path}")
260
+
261
+ browser = p.chromium.launch(
262
+ headless=True,
263
+ executable_path=executable_path
264
+ )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
265
 
266
  page = browser.new_page()
267
  page.goto(url)