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 镜像硒
基础教程推荐
- 与常规 dict 相比,Python manager.dict() 非常慢 2022-01-01
- pyserial - 可以从线程 a 写入串行端口,是否阻塞从线程 b 读取? 2022-01-01
- 尝试制作WhatsApp机器人 2022-01-01
- 由Python将MP3转换为MIDI(类型错误:无法加载插件:mtg-Melodia:Melodia) 2022-01-01
- Discord.py 缺少必需的参数 2022-01-01
- numpy float:比算术运算中内置的慢 10 倍? 2022-01-01
- 在 Celery 工作人员中捕获 Heroku SIGTERM 以优雅地关 2022-01-01
- 使用生成器和迭代器时 Python 多循环失败 2022-01-01
- 用 Python 编写 Fortran 无格式文件 2022-01-01
- 将 x 轴刻度更改为自定义字符串 2022-01-01
