我正在尝试在pythonanywhere服务器上使用selenium,webdriver和xvfb运行我的搜寻器(如果有帮助的话)。我还尝试使用pyvirtualdisplay而不是xvfb为webdriver创建浏览器窗口。但是我一直收到错误 “消息:服务/ usr / bin / chromium-browser意外退出。状态代码为:127”
跟踪:
内部文件“ /home/Sayn0toWar/.virtualenvs/parser/lib/python3.7/site-packages/django/core/handlers/exception.py” 34. response = get_response(request)
_get_response中的文件“ /home/Sayn0toWar/.virtualenvs/parser/lib/python3.7/site-packages/django/core/handlers/base.py” 115. response = self.process_exception_by_middleware(e,request)
_get_response中的文件“ /home/Sayn0toWar/.virtualenvs/parser/lib/python3.7/site-packages/django/core/handlers/base.py” 113. response = wrapd_callback(request,* callback_args,** callback_kwargs)
索引中的文件“ /home/Sayn0toWar/parser_test/parser_test/main/views.py” 13. main(int(iterations))
主文件“ /home/Sayn0toWar/parser_test/parser_test/main/parser_script.py” 111. b = Bot(迭代)
初始化中的文件“ /home/Sayn0toWar/parser_test/parser_test/main/parser_script.py” 24. self.driver = webdriver.Chrome(executable_path ='/ usr / bin / chromium-browser',chrome_options = options)
初始化中的文件“ /home/Sayn0toWar/.virtualenvs/parser/lib/python3.7/site-packages/selenium/webdriver/chrome/webdriver.py” 73. self.service.start()
文件“ /home/Sayn0toWar/.virtualenvs/parser/lib/python3.7/site-packages/selenium/webdriver/common/service.py”开始 98. self.assert_process_still_running()
assert_process_still_running中的文件“ /home/Sayn0toWar/.virtualenvs/parser/lib/python3.7/site-packages/selenium/webdriver/common/service.py” 111.%(self.path,return_code)
异常类型:/处的WebDriverException 异常值:消息:服务/ usr / bin / chromium-browser意外退出。状态码为:127
我的代码:
from bs4 import BeautifulSoup
from selenium import webdriver
from webdrivermanager import ChromeDriverManager
from xvfbwrapper import Xvfb
from pyvirtualdisplay import Display
from time import sleep
class Bot:
def __init__(self, iterations):
display = Display(visible=0, size=(800, 600))
display.start()
cdm = ChromeDriverManager()
chromedriver_path = cdm.download_and_install()
options = webdriver.ChromeOptions()
options.add_argument('--headless')
options.add_argument('--no-sandbox')
self.driver = webdriver.Chrome(executable_path='/usr/bin/chromium-browser', chrome_options=options)
self.navigate(iterations)
self.close()
display.stop()
对我的代码感到抱歉,我还不擅长python,并且只是想使脚本工作几天,在我看来,已经访问了包含有关此错误的任何信息的所有资源。 Chrome和chromedriver都具有相同的版本78,并已安装所有必需的依赖项。而且我不知道我还能做什么。 可以帮忙吗?