Spaces:
Running
Running
Commit ·
47135f7
1
Parent(s): 5836de2
Porject Uploaded
Browse files- Dockerfile +9 -2
- worker.py +10 -5
Dockerfile
CHANGED
|
@@ -4,6 +4,8 @@ WORKDIR /app
|
|
| 4 |
|
| 5 |
ENV DEBIAN_FRONTEND=noninteractive
|
| 6 |
ENV TZ=Etc/UTC
|
|
|
|
|
|
|
| 7 |
|
| 8 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 9 |
wget \
|
|
@@ -20,10 +22,15 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
| 20 |
libgtk-3-0 \
|
| 21 |
&& rm -rf /var/lib/apt/lists/*
|
| 22 |
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 25 |
|
| 26 |
-
COPY . .
|
| 27 |
|
| 28 |
EXPOSE 7860
|
| 29 |
|
|
|
|
| 4 |
|
| 5 |
ENV DEBIAN_FRONTEND=noninteractive
|
| 6 |
ENV TZ=Etc/UTC
|
| 7 |
+
ENV WDM_PROGRESS_BAR=0
|
| 8 |
+
ENV HOME=/home/appuser
|
| 9 |
|
| 10 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 11 |
wget \
|
|
|
|
| 22 |
libgtk-3-0 \
|
| 23 |
&& rm -rf /var/lib/apt/lists/*
|
| 24 |
|
| 25 |
+
RUN addgroup --system appuser && adduser --system --ingroup appuser appuser
|
| 26 |
+
RUN chown -R appuser:appuser /app
|
| 27 |
+
|
| 28 |
+
USER appuser
|
| 29 |
+
|
| 30 |
+
COPY --chown=appuser:appuser requirements.txt .
|
| 31 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 32 |
|
| 33 |
+
COPY --chown=appuser:appuser . .
|
| 34 |
|
| 35 |
EXPOSE 7860
|
| 36 |
|
worker.py
CHANGED
|
@@ -1,11 +1,13 @@
|
|
| 1 |
import pandas as pd
|
| 2 |
import time
|
| 3 |
import io
|
|
|
|
| 4 |
import threading
|
| 5 |
from selenium import webdriver
|
| 6 |
from selenium.webdriver.chrome.service import Service as ChromeService
|
| 7 |
from selenium.webdriver.chrome.options import Options as ChromeOptions
|
| 8 |
-
|
|
|
|
| 9 |
from selenium.webdriver.common.by import By
|
| 10 |
from selenium.webdriver.support.ui import WebDriverWait
|
| 11 |
from selenium.webdriver.support import expected_conditions as EC
|
|
@@ -26,13 +28,16 @@ class QuantumBot:
|
|
| 26 |
options.add_argument(f'user-agent={user_agent}')
|
| 27 |
options.add_argument("--headless")
|
| 28 |
options.add_argument("--window-size=1920,1080")
|
| 29 |
-
options.add_argument("--no-sandbox")
|
| 30 |
-
options.add_argument("--disable-dev-shm-usage")
|
| 31 |
options.add_argument('--disable-blink-features=AutomationControlled')
|
| 32 |
options.add_experimental_option("excludeSwitches", ["enable-automation"])
|
| 33 |
options.add_experimental_option('useAutomationExtension', False)
|
| 34 |
-
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
| 36 |
self.driver = webdriver.Chrome(service=service, options=options)
|
| 37 |
|
| 38 |
self.driver.execute_cdp_cmd('Page.addScriptToEvaluateOnNewDocument', {
|
|
|
|
| 1 |
import pandas as pd
|
| 2 |
import time
|
| 3 |
import io
|
| 4 |
+
import os
|
| 5 |
import threading
|
| 6 |
from selenium import webdriver
|
| 7 |
from selenium.webdriver.chrome.service import Service as ChromeService
|
| 8 |
from selenium.webdriver.chrome.options import Options as ChromeOptions
|
| 9 |
+
from webdriver_manager.chrome import ChromeDriverManager
|
| 10 |
+
from webdriver_manager.core.utils import ChromeType
|
| 11 |
from selenium.webdriver.common.by import By
|
| 12 |
from selenium.webdriver.support.ui import WebDriverWait
|
| 13 |
from selenium.webdriver.support import expected_conditions as EC
|
|
|
|
| 28 |
options.add_argument(f'user-agent={user_agent}')
|
| 29 |
options.add_argument("--headless")
|
| 30 |
options.add_argument("--window-size=1920,1080")
|
| 31 |
+
options.add_argument("--no-sandbox")
|
| 32 |
+
options.add_argument("--disable-dev-shm-usage")
|
| 33 |
options.add_argument('--disable-blink-features=AutomationControlled')
|
| 34 |
options.add_experimental_option("excludeSwitches", ["enable-automation"])
|
| 35 |
options.add_experimental_option('useAutomationExtension', False)
|
| 36 |
+
|
| 37 |
+
# --- Definitive Fix: Use a writable cache path ---
|
| 38 |
+
os.environ['WDM_LOCAL'] = '/home/appuser/.wdm'
|
| 39 |
+
service = ChromeService(ChromeDriverManager(chrome_type=ChromeType.CHROMIUM).install())
|
| 40 |
+
|
| 41 |
self.driver = webdriver.Chrome(service=service, options=options)
|
| 42 |
|
| 43 |
self.driver.execute_cdp_cmd('Page.addScriptToEvaluateOnNewDocument', {
|