Docker image with python3, chromedriver, chrome amp; selenium(带有 python3、chromedriver、chrome amp; 的 Docker 镜像硒)
问题描述
我的目标是使用由 Selenium 抓取网络.python.org/" rel="noreferrer">Python 来自 docker 容器.
我四处寻找并没有找到安装了以下所有内容的 docker 映像:
- Python 3
- ChromeDriver
- Chrome
- 硒
是否有人可以将我链接到 docker image 与所有这些已安装并一起工作?
也许建立我自己的并没有我想象的那么困难,但到目前为止它已经暗示了我.
任何和所有建议都表示赞赏.
试试https://github.com/SeleniumHQ/docker-selenium.
它已经安装了python:
$ docker run selenium/standalone-chrome python3 --versionPython 3.5.2
说明表明您开始使用它
docker run -d -p 4444:4444 --shm-size=2g selenium/standalone-chrome
要允许 selenium 通过 python 运行,您似乎需要安装软件包.创建这个 Dockerfile
:
来自 selenium/standalone-chrome用户根运行 wget https://bootstrap.pypa.io/get-pip.py运行 python3 get-pip.py运行 python3 -m pip install selenium
然后你可以运行它
docker 构建.-t 硒铬 &&docker run -it selenium-chrome python3
与普通的 python
docker 镜像相比,优势在于您不需要安装 chromedriver 本身,因为它来自 selenium/standalone-chrome
.p>
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:
- Python 3
- ChromeDriver
- Chrome
- Selenium
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 & 的 Docker 镜像硒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:带有 python3、chromedriver、chrome & 的 Docker 镜像硒


基础教程推荐
- 修改列表中的数据帧不起作用 2022-01-01
- Plotly:如何设置绘图图形的样式,使其不显示缺失日期的间隙? 2022-01-01
- 在Python中从Azure BLOB存储中读取文件 2022-01-01
- PANDA VALUE_COUNTS包含GROUP BY之前的所有值 2022-01-01
- 求两个直方图的卷积 2022-01-01
- 在同一图形上绘制Bokeh的烛台和音量条 2022-01-01
- 包装空间模型 2022-01-01
- PermissionError: pip 从 8.1.1 升级到 8.1.2 2022-01-01
- 无法导入 Pytorch [WinError 126] 找不到指定的模块 2022-01-01
- 使用大型矩阵时禁止 Pycharm 输出中的自动换行符 2022-01-01