scrapy Heroku chromedriver和google-chrome构建包在使用时崩溃

ylamdve6  于 2022-11-09  发布在  Go
关注(0)|答案(1)|浏览(144)

使用scrapy和heroku的一些蜘蛛我已经设置。它的工作几个月很好,没有改变任何东西,我知道会有任何影响,但当我试图运行一个蜘蛛,我得到这个错误。

2021-03-03 04:13:33 [selenium.webdriver.remote.remote_connection] DEBUG: Finished Request
2021-03-03 04:13:33 [twisted] CRITICAL: Unhandled error in Deferred:
2021-03-03 04:13:33 [twisted] CRITICAL: 
Traceback (most recent call last):
  File "/app/.heroku/python/lib/python3.7/site-packages/twisted/internet/defer.py", line 1418, in _inlineCallbacks
    result = g.send(result)
  File "/app/.heroku/python/lib/python3.7/site-packages/scrapy/crawler.py", line 87, in crawl
    self.engine = self._create_engine()
  File "/app/.heroku/python/lib/python3.7/site-packages/scrapy/crawler.py", line 101, in _create_engine
    return ExecutionEngine(self, lambda _: self.stop())
  File "/app/.heroku/python/lib/python3.7/site-packages/scrapy/core/engine.py", line 69, in __init__
    self.downloader = downloader_cls(crawler)
  File "/app/.heroku/python/lib/python3.7/site-packages/scrapy/core/downloader/__init__.py", line 83, in __init__
    self.middleware = DownloaderMiddlewareManager.from_crawler(crawler)
  File "/app/.heroku/python/lib/python3.7/site-packages/scrapy/middleware.py", line 53, in from_crawler
    return cls.from_settings(crawler.settings, crawler)
  File "/app/.heroku/python/lib/python3.7/site-packages/scrapy/middleware.py", line 35, in from_settings
    mw = create_instance(mwcls, settings, crawler)
  File "/app/.heroku/python/lib/python3.7/site-packages/scrapy/utils/misc.py", line 150, in create_instance
    instance = objcls.from_crawler(crawler, *args,**kwargs)
  File "/app/.heroku/python/lib/python3.7/site-packages/scrapy_selenium/middlewares.py", line 71, in from_crawler
    browser_executable_path=browser_executable_path
  File "/app/.heroku/python/lib/python3.7/site-packages/scrapy_selenium/middlewares.py", line 51, in __init__
    self.driver = driver_klass(**driver_kwargs)
  File "/app/.heroku/python/lib/python3.7/site-packages/selenium/webdriver/chrome/webdriver.py", line 81, in __init__
    desired_capabilities=desired_capabilities)
  File "/app/.heroku/python/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__
    self.start_session(capabilities, browser_profile)
  File "/app/.heroku/python/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/app/.heroku/python/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/app/.heroku/python/lib/python3.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally.
  (unknown error: DevToolsActivePort file doesn't exist)
  (The process started from chrome location /app/.apt/opt/google/chrome/chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
scyqe7ek

scyqe7ek1#

我也遇到了同样的情况,我在git仓库里找到了一个issue和一个pull request,所以我想我们只能等它被接受了。
编辑:有一个fix。我测试了一下,它工作了!
1.添加构建包:https://github.com/heroku/heroku-buildpack-apt
1.创建一个名为Aptfile的文件,并将libxshmfence-dev粘贴到该文件中。

相关问题