Spaces:
Running
Running
Updated chromium driver installation
Browse files- Dockerfile +10 -3
- code/web_scraper_allegro.py +8 -13
- code/web_scraper_ebay.py +8 -13
Dockerfile
CHANGED
|
@@ -2,12 +2,19 @@ FROM python:3.10
|
|
| 2 |
|
| 3 |
WORKDIR /app
|
| 4 |
|
| 5 |
-
# Install system dependencies for Chrome
|
| 6 |
RUN apt-get update && apt-get install -y \
|
| 7 |
-
|
| 8 |
-
|
|
|
|
| 9 |
&& rm -rf /var/lib/apt/lists/*
|
| 10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
# Copy requirements first for better caching
|
| 12 |
COPY requirements.txt .
|
| 13 |
|
|
|
|
| 2 |
|
| 3 |
WORKDIR /app
|
| 4 |
|
| 5 |
+
# Install system dependencies for Chrome
|
| 6 |
RUN apt-get update && apt-get install -y \
|
| 7 |
+
wget \
|
| 8 |
+
gnupg \
|
| 9 |
+
unzip \
|
| 10 |
&& rm -rf /var/lib/apt/lists/*
|
| 11 |
|
| 12 |
+
# Add Google Chrome repository and install Chrome
|
| 13 |
+
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \
|
| 14 |
+
sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list' && \
|
| 15 |
+
apt-get update && apt-get install -y google-chrome-stable && \
|
| 16 |
+
rm -rf /var/lib/apt/lists/*
|
| 17 |
+
|
| 18 |
# Copy requirements first for better caching
|
| 19 |
COPY requirements.txt .
|
| 20 |
|
code/web_scraper_allegro.py
CHANGED
|
@@ -33,20 +33,15 @@ def scrape_allegro_offer(url: str):
|
|
| 33 |
options.add_argument("--no-sandbox")
|
| 34 |
options.add_argument("--disable-dev-shm-usage")
|
| 35 |
|
| 36 |
-
# Ustawienie binarki Chrome'a
|
| 37 |
-
if os.path.exists('/usr/bin/
|
| 38 |
-
options.binary_location = '/usr/bin/
|
| 39 |
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
)
|
| 46 |
-
except Exception as e:
|
| 47 |
-
print(f"Error initializing Chrome with webdriver-manager: {e}")
|
| 48 |
-
# Fallback: próbuj bez service
|
| 49 |
-
driver = uc.Chrome(options=options, use_subprocess=True)
|
| 50 |
|
| 51 |
try:
|
| 52 |
print(f"🔍 Allegro: {url}")
|
|
|
|
| 33 |
options.add_argument("--no-sandbox")
|
| 34 |
options.add_argument("--disable-dev-shm-usage")
|
| 35 |
|
| 36 |
+
# Ustawienie binarki Chrome'a
|
| 37 |
+
if os.path.exists('/usr/bin/google-chrome'):
|
| 38 |
+
options.binary_location = '/usr/bin/google-chrome'
|
| 39 |
|
| 40 |
+
driver = uc.Chrome(
|
| 41 |
+
service=Service(ChromeDriverManager().install()),
|
| 42 |
+
options=options,
|
| 43 |
+
use_subprocess=True
|
| 44 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
|
| 46 |
try:
|
| 47 |
print(f"🔍 Allegro: {url}")
|
code/web_scraper_ebay.py
CHANGED
|
@@ -16,20 +16,15 @@ def scrape_ebay_offer(url: str):
|
|
| 16 |
options.add_argument("--no-sandbox")
|
| 17 |
options.add_argument("--disable-dev-shm-usage")
|
| 18 |
|
| 19 |
-
# Ustawienie binarki Chrome'a
|
| 20 |
-
if os.path.exists('/usr/bin/
|
| 21 |
-
options.binary_location = '/usr/bin/
|
| 22 |
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
)
|
| 29 |
-
except Exception as e:
|
| 30 |
-
print(f"Error initializing Chrome with webdriver-manager: {e}")
|
| 31 |
-
# Fallback: próbuj bez service
|
| 32 |
-
driver = uc.Chrome(options=options, use_subprocess=True)
|
| 33 |
|
| 34 |
try:
|
| 35 |
driver.get(url)
|
|
|
|
| 16 |
options.add_argument("--no-sandbox")
|
| 17 |
options.add_argument("--disable-dev-shm-usage")
|
| 18 |
|
| 19 |
+
# Ustawienie binarki Chrome'a
|
| 20 |
+
if os.path.exists('/usr/bin/google-chrome'):
|
| 21 |
+
options.binary_location = '/usr/bin/google-chrome'
|
| 22 |
|
| 23 |
+
driver = uc.Chrome(
|
| 24 |
+
service=Service(ChromeDriverManager().install()),
|
| 25 |
+
options=options,
|
| 26 |
+
use_subprocess=True
|
| 27 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
try:
|
| 30 |
driver.get(url)
|