简体   繁体   English

无法在 python 中使用带有硒的 Chromedriver 消除音频错误

[英]Can't silence audio errors using Chromedriver with selenium in python

I'm running a python script to scrape some webpages and am using selenium + chromedriver.我正在运行一个 python 脚本来抓取一些网页,并且正在使用 selenium + chromedriver。 The script is working fine and doing what it's meant to do without crashing, howver chromedriver is logging audio errors that I can't silence.该脚本运行良好,并且在不崩溃的情况下完成了它应该做的事情,但是 chromedriver 正在记录我无法静音的音频错误。

错误日志

I'm using log-level 3 so that only fatal errors should print, but I'm still getting the above.我正在使用日志级别 3,以便只打印致命错误,但我仍然得到上述信息。 I also tried the option to disable logging and again I still got the same output as above.我还尝试了禁用日志记录的选项,但我仍然得到与上面相同的输出。

options = webdriver.ChromeOptions() 
options.add_argument('--disable-gpu')
options.add_argument('--start-maximized')
options.add_argument('--log-level=3')
#options.add_argument('--disable-logging')

driver = webdriver.Chrome(chrome_options = options)
driver.get(link)

Any help to get round this would be greatly appreciated!任何帮助解决这个问题将不胜感激!

Just try using the --mute-audio argument this should disable the audio.只需尝试使用--mute-audio参数即可禁用音频。

like this:像这样:

options = webdriver.ChromeOptions() 
options.add_argument('--disable-gpu')
options.add_argument('--start-maximized')
options.add_argument('--log-level=3')
# options.add_argument('--disable-logging')
options.add_argument("--mute-audio")

driver = webdriver.Chrome(chrome_options = options)
driver.get(link)

EDIT:编辑:

Try using logging (this is based on this answer ):尝试使用 日志记录(这是基于这个答案):

import logging
from selenium.webdriver.remote.remote_connection import LOGGER


LOGGER.setLevel(logging.WARNING)
options = webdriver.ChromeOptions()


options.add_argument('--disable-gpu')
options.add_argument('--start-maximized')
options.add_argument('--log-level=3')
# options.add_argument('--disable-logging')
options.add_argument("--mute-audio")

driver = webdriver.Chrome(chrome_options = options)
driver.get(link)

Hope this helps you!希望这对你有帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM