From cfe7a3e00292992c6c53891a1d3d253f898a80bf Mon Sep 17 00:00:00 2001 From: sgrtye Date: Sun, 29 Sep 2024 21:10:31 +0100 Subject: [PATCH] pre-install drivers and use headless mode --- novel/Dockerfile | 1 + novel/main.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/novel/Dockerfile b/novel/Dockerfile index 6e86af1..32dea0e 100644 --- a/novel/Dockerfile +++ b/novel/Dockerfile @@ -16,6 +16,7 @@ RUN apt-get clean && rm -rf /var/lib/apt/lists/* COPY . /app RUN pip install --no-cache-dir -r /app/requirements.txt +RUN seleniumbase get chromedriver --path RUN pyarmor gen --output /app /app/main.py HEALTHCHECK --start-period=10s --interval=60s --timeout=3s CMD curl -f http://localhost:80/health || exit 1 diff --git a/novel/main.py b/novel/main.py index ce50fc8..04fc61e 100644 --- a/novel/main.py +++ b/novel/main.py @@ -100,7 +100,7 @@ def load_cache(): def get_url_html(url, proxy=None): try: - with SB(uc=True, proxy=proxy) as sb: + with SB(uc=True, proxy=proxy, headless2=True) as sb: sb.uc_open_with_reconnect(url, 5) sb.uc_gui_click_captcha() return sb.get_page_source()