Bil*_*hon 5 selenium scrapy selenium-chromedriver
我将 selenium 与 Scrapy 一起使用,它会产生太多的日志。
我之前尝试过 SO 提供的几种解决方案,但都没有奏效。基本上我尝试禁用它options并传递service-argument将日志写入文件。在这两种情况下,日志在执行时仍会打印。我如何解决它?
options = Options()
options.headless = True
# options.add_argument('--disable-logging')
self.driver = webdriver.Chrome(r'C:\Python3\selenium\webdriver\chromedriver_win32\chromedriver.exe', chrome_options=options, service_args=["--verbose", "--log-path=D:\\qc1.log"])
Run Code Online (Sandbox Code Playgroud)
我还尝试将服务路径设置为NULL(我运行 Windows)
self.driver = `webdriver.Chrome(r'C:\Python3\selenium\webdriver\chromedriver_win32\chromedriver.exe', chrome_options=options, service_log_path='NUL')`
Run Code Online (Sandbox Code Playgroud)
解决方案: 感谢 - @Manmohan_singh 和 迄今为止唯一有效的答案 添加这个
chrome_options.add_argument("--log-level=3") to shut the logging.
self.driver = webdriver.Chrome(r'C:\Python3\selenium\webdriver\chromedriver_win32\chromedriver.exe', chrome_options=options)
Run Code Online (Sandbox Code Playgroud)
希望这在未来会有用,因为没有一个可能重复的主题对我有帮助,而且 Stack 版主似乎没有仔细阅读这些帖子。
| 归档时间: |
|
| 查看次数: |
4116 次 |
| 最近记录: |