Python3应用程序,使用砷库异步网络报废。它需要带有驱动程序的浏览器。所有的测试都是在windows py魅力上测试的,因为我安装了Chrome操作系统。现在我必须使用在AmazonUbuntu20.04服务器上构建我的应用程序,我尝试了许多不同的方法,但仍然无法使它工作…下面是我的停靠程序和python代码的一部分:
我的Dockerfile:
FROM python:latest
WORKDIR /src
COPY requirements.txt /src
RUN pip install -r requirements.txt
COPY . /src我的船坞-写作:
version: '3.1'
services:
tgbot:
container_name: bot
build:
context: .
command: python app.py
restart: always
environment:
WEBAPP_PORT: 3001
env_file:
- ".env"
# bot start after load db
ports:
- 8443:3001
networks:
- botnet
volumes:
- ./:/src
networks:
botnet:
driver: bridgerequirements.txt包括arsenic~=20.9
Python代码,在我的windows PC上使用砷(我已经安装了chrome,+ app文件夹中的chromedriver文件):
from arsenic import get_session, keys, browsers, services
async def arsenic_scraper(url):
service = services.Chromedriver() # here is driver, if empty - it should find from PATH, or path to driver
browser = browsers.Chrome()
async with get_session(service, browser) as session:
await session.get(url)发布于 2020-12-13 07:24:28
你还没有在你的对接映像中安装铬和铬驱动器,所以你的应用程序找不到它们。由于官方python docker映像使用Debian,所以您可以尝试在docker映像中使用
RUN apt-get install -y google-chrome-stable
并下载兼容版本的色驱动程序,可能与wget兼容。检查应使用哪个版本的chromedriver文档:https://chromedriver.chromium.org/
然后,确保应用程序在下载chromedriver的目录中。
https://askubuntu.com/questions/1299283
复制相似问题