-
-
Save Faq/8821c5fd18dd01da4f80d7435158096d to your computer and use it in GitHub Desktop.
| Source: https://gist.github.com/varyonic/dea40abcf3dd891d204ef235c6e8dd79 | |
| Change log: | |
| 1. replaced "dl-ssl.google.com" with "dl.google.com" according https://www.google.com/linuxrepositories/ | |
| 2. replaced "apt-key" as "Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8))." | |
| 3. use https | |
| 4. use npm package as previous solution didnt work | |
| Oneliner for Dockerfile: | |
| # Install latest Chrome for Testing and ChromeDriver | |
| # https://github.com/GoogleChromeLabs/chrome-for-testing?tab=readme-ov-file#whats-the-easiest-way-to-download-chrome-for-testing-binaries | |
| RUN npx @puppeteer/browsers install chrome@stable --install-deps --path "/opt"; \ | |
| npx @puppeteer/browsers install chromedriver@stable --path "/opt"; | |
| # Create symlinks to make chrome and chromedriver available in PATH | |
| RUN ln -s $(find /opt/chrome -name chrome -type f | head -n 1) /usr/local/bin/google-chrome; \ | |
| ln -s $(find /opt/chromedriver -name chromedriver -type f | head -n 1) /usr/local/bin/chromedriver; | |
| # To check it after (chrome and chromedriver versions will be the same): | |
| $ docker run --rm -it put_docker_image_name_here bash | |
| $ google-chrome --version | |
| $ chromedriver -v |
@lrodden why chrome-for-testing-public? It is not stable.
@Faq according to the chromedriver developers, any version past 115 should be accessed through that repo ^^ (ref -> https://chromedriver.chromium.org/downloads). There is a Chrome STABLE version which directly corresponds to the current stable version of chromedriver.
https://dl.google.com/linux/chrome/deb/ returns a 404
https://dl.google.com/linux/chrome/deb/ returns a 404
@gharmeling Not running the full command
The command you suggested (updated for 2024) results (for me) in
3.944 E: Unable to locate package google-chrome-stable
I am running docker on a Mac Book M1
Would you have any idea why?
Did someone manage to fix these issues with Unable to locate package google-chrome-stable and https://dl.google.com/linux/chrome/deb/ returning 404?
I'm encountering this problem also. Any ideas on how to resolve?
This is the current working method for me:
RUN curl -LO https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb && \
apt-get install -y ./google-chrome-stable_current_amd64.deb && \
rm google-chrome-stable_current_amd64.deb
Works on Mac with Apple Silicon, but make sure you are running your image as platform: linux/amd64
FROM --platform=linux/amd64 python:3.12-slim
WORKDIR /app
RUN apt-get update && apt-get install -y wget curl unzip gnupg --no-install-recommends
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | \
gpg --no-default-keyring --keyring gnupg-ring:/etc/apt/trusted.gpg.d/google.gpg --import; \
chmod 644 /etc/apt/trusted.gpg.d/google.gpg; \
echo "deb http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google-chrome.list
RUN curl -LO https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb && \
apt-get install -y ./google-chrome-stable_current_amd64.deb && \
rm google-chrome-stable_current_amd64.deb
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
CMD ["python", "test_crawler.py"]
This is my docker file. I am crawling using requests_html. I am facing the issue of html.render() function getting freezed and not executing. My system is Mac with Apple Silicon. Same docker was working fine on a Windows machine.
Recommend updating this for 2024: