带有python3,chromedriver,chrome&的Docker映像硒 [英] Docker image with python3, chromedriver, chrome & selenium

查看:173
本文介绍了带有python3,chromedriver,chrome&的Docker映像硒的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的目标是使用 Selenium 抓取网络。 www.python.org/ rel = nofollow noreferrer> Python 来自 docker < a href = https://www.docker.com/resources/what-c​​ontainer rel = nofollow noreferrer>容器。



我ve到处寻找并没有找到安装了以下所有程序的docker映像:





有人可以将我链接到 docker image 并安装了所有这些并且可以一起工作吗?



也许构建自己的镜像并不像我认为,但是到目前为止,这已经暗示了我。



任何人和所有建议都值得赞赏。

解决方案

尝试 https://github.com/SeleniumHQ/docker-selenium



它已安装python:

  $ docker run selenium / standalone -chrome python3 --version 
Python 3.5.2

说明指示您以

  docker run -d -p 4444:4444 --shm-size = 2g硒/独立铬

编辑:



允许Selenium通过python运行,看来您需要安装软件包。创建以下 Dockerfile

  FROM硒/独立铬

用户root
运行wget https://bootstrap.pypa.io/get-pip.py
运行python3 get-pip.py
运行python3 -m pip安装硒

然后您可以使用



<$ p运行它$ p> docker build。 -t硒铬b
docker run -it selenium-chrome python3

与普通相比的优势 python 泊坞窗映像是,您不需要安装chromedriver本身,因为它来自 selenium / standalone-chrome


My objective is to scrape the web with Selenium driven by Python from a docker container.

I've looked around for and not found a docker image with all of the following installed:

Is anyone able to link me to a docker image with all of these installed and working together?

Perhaps building my own isn't as difficult as I think, but it's alluded me thus far.

Any and all advice appreciated.

解决方案

Try https://github.com/SeleniumHQ/docker-selenium.

It has python installed:

$ docker run selenium/standalone-chrome python3 --version
Python 3.5.2

The instructions indicate you start it with

docker run -d -p 4444:4444 --shm-size=2g selenium/standalone-chrome

Edit:

To allow selenium to run through python it appears you need to install the packages. Create this Dockerfile:

FROM selenium/standalone-chrome

USER root
RUN wget https://bootstrap.pypa.io/get-pip.py
RUN python3 get-pip.py
RUN python3 -m pip install selenium

Then you could run it with

docker build . -t selenium-chrome && \
    docker run -it selenium-chrome python3

The advantage compared to the plain python docker image is that you won't need to install the chromedriver itself since it comes from selenium/standalone-chrome.

这篇关于带有python3,chromedriver,chrome&amp;的Docker映像硒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆