0

I have a website made using Django, click a button on the website triggers a scraper to start. This scraper uses selenium. I have added the following two build packs needed for selenium to my heroku app:

1) https://github.com/heroku/heroku-buildpack-chromedriver

2) https://github.com/heroku/heroku-buildpack-google-chrome

chrome_options = webdriver.ChromeOptions()
chrome_options.binary_location='/app/.apt/usr/bin/google-chrome'
os.environ.get("GOOGLE_CHROME_BIN", "chromedriver")
browser=webdriver.Chrome(executable_path=os.environ.get("GOOGLE_CHROME_BIN", "chromedriver"),chrome_options=chrome_options)

But yet it fails to find the chromedriver and throws the error chromedriver needs to be in PATH, how to fix this issue? Where is the chromedriver executable?

1 Answer 1

2

I wanted to comment you the link, where I previously answered this question, but I don't have enough rep to comment, so anywho here you go..

Set the following path using heroku congfig:set command

heroku config:set CHROMEDRIVER_PATH=/app/.chromedriver/bin/chromedriver and heroku config:set GOOGLE_CHROME_BIN=/app/.apt/usr/bin/google-chrome

Verify the paths using heroku config command

You can use this snippet to configure your definition

import os
from selenium import webdriver
from selenium.webdriver.chrome.options import Options

def load_chrome_driver(proxy):

      options = Options()

      options.binary_location = os.environ.get('GOOGLE_CHROME_BIN')

      options.add_argument('--headless')
      options.add_argument('--disable-gpu')
      options.add_argument('--no-sandbox')
      options.add_argument('--remote-debugging-port=9222')
      options.add_argument('--proxy-server='+proxy)

      return webdriver.Chrome(executable_path=str(os.environ.get('CHROMEDRIVER_PATH')), chrome_options=options)

I'm using proxies, but you can probably avoid that.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.