How to disable or change the path of ghostdriver.log?

前端 未结 2 1546
死守一世寂寞
死守一世寂寞 2021-02-01 17:03

Question is straightfoward, but some context may help.

I\'m trying to deploy scrapy while using selenium and phantomjs as downloader. But the problem is that it keeps on

相关标签:
2条回答
  • 2021-02-01 17:17

    When using the PhantomJS driver add the following parameter:

    driver = webdriver.PhantomJS(service_log_path='/var/log/phantomjs/ghostdriver.log')
    

    Related code, would be nice to have an option to turn off logging though, seems thats not supported:

    selenium/webdriver/phantomjs/service.py

    class Service(object):
        """
        Object that manages the starting and stopping of PhantomJS / Ghostdriver
        """
    
        def __init__(self, executable_path, port=0, service_args=None, log_path=None):
            """
            Creates a new instance of the Service
    
            :Args:
             - executable_path : Path to PhantomJS binary
             - port : Port the service is running on
             - service_args : A List of other command line options to pass to PhantomJS
             - log_path: Path for PhantomJS service to log to
            """
    
            self.port = port
            self.path = executable_path
            self.service_args= service_args
            if self.port == 0:
                self.port = utils.free_port()
            if self.service_args is None:
                self.service_args = []
            self.service_args.insert(0, self.path)
            self.service_args.append("--webdriver=%d" % self.port)
            if not log_path:
                log_path = "ghostdriver.log"
            self._log = open(log_path, 'w')
    
    0 讨论(0)
  • 2021-02-01 17:24
        #Reduce logging level
        driver = webdriver.PhantomJS(service_args=["--webdriver-loglevel=SEVERE"])
    
        #Remove logging
        import os
        driver = webdriver.PhantomJS(service_log_path=os.path.devnull)
    
    0 讨论(0)
提交回复
热议问题