Вопрос о задании пути к chromedriver в buildpack-пакете chromedriver для heroku - PullRequest
0 голосов
/ 03 сентября 2018

Я пытаюсь настроить селен и хромедривер на героку. а стека это героку-16 но я столкнулся с проблемой ниже во время установки. Как установить путь к хромедрайверу в пакете сборки?

$ Heroku buildpacks

1. heroku/python
2. https://github.com/heroku/heroku-buildpack-chromedriver
3. https://github.com/notvad/heroku-buildpack-selenium.git
4. https://github.com/heroku/heroku-buildpack-chromedriver.git

Параметр

CHROMEDRIVER_PATH = "/app/.chromedriver/bin/chromedriver"
GOOGLE_CHROME_BIN = "/app/.apt/usr/bin/google-chrome

Код Sorce:

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.chrome.options import Options as ChromeOptions
from bs4 import BeautifulSoup as bs
import pickle
import os

GOOGLE_CHROME_BIN = os.environ.get('GOOGLE_CHROME_BIN')
CHROMEDRIVER_PATH = os.environ.get('CHROMEDRIVER_PATH')
opts = ChromeOptions()      
opts.binary_location = GOOGLE_CHROME_BIN
opts.add_argument('--headless') 
opts.add_argument('--disable-gpu')
opts.add_argument('--no-sandbox')
driver = webdriver.Chrome(executable_path=CHROMEDRIVER_PATH,chrome_options=opts)

Код ошибки:

Traceback (most recent call last):
  File "Monitoring.py", line 28, in <module>
    driver = webdriver.Chrome(executable_path=CHROMEDRIVER_PATH, chrome_options=opts)
  File "/app/.heroku/python/lib/python3.6/site-packages/selenium/webdriver/chrome/webdriver.py", line 68, in __init__
    self.service.start()
  File "/app/.heroku/python/lib/python3.6/site-packages/selenium/webdriver/common/service.py", line 98, in start
    self.assert_process_still_running()
  File "/app/.heroku/python/lib/python3.6/site-packages/selenium/webdriver/common/service.py", line 111, in assert_process_still_running
    % (self.path, return_code)
selenium.common.exceptions.WebDriverException: Message: Service /app/.chromedriver/bin/chromedriver unexpectedly exited. Status code was: 127

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "Monitoring.py", line 84, in <module>
    driver.quit()
NameError: name 'driver' is not defined
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...