GoogleScraper icon indicating copy to clipboard operation
GoogleScraper copied to clipboard

Ability to launch chromedriver in headless mode

Open arkochhar opened this issue 7 years ago • 0 comments

Sample code that I changed to get this running of Linux server (with no GUI)

    def _get_Chrome(self):
        try:
            #service_log_path = 'chromedriver.log'
            #service_args = ['--verbose']
            chrome_ops = webdriver.ChromeOptions()
            chrome_ops.add_argument('--headless')
            chrome_ops.add_argument('--no-sandbox')
            if self.proxy:
                chrome_ops.add_argument(
                    '--proxy-server={}://{}:{}'.format(self.proxy.proto, self.proxy.host, self.proxy.port))
            self.webdriver = webdriver.Chrome(chrome_options=chrome_ops) #, service_args=service_args, service_log_path=service_log_path)
            #else:
            #    self.webdriver = webdriver.Chrome()#service_log_path='/tmp/chromedriver_log.log')
            return True
        except WebDriverException as e:
            # we don't have a chrome executable or a chrome webdriver installed
            raise
        return False

arkochhar avatar Jul 31 '18 13:07 arkochhar