Python 无头镀铬驱动蟒蛇“;未捕获标记错误“;
在Windows 7、Python 3.6.4、Selenium 3.9.0和Chromedriver 2.43上运行代码时,代码在非headless模式下执行时不会出现问题。在无头模式下,在Anaconda提示符下执行,连续输出以下错误:Python 无头镀铬驱动蟒蛇“;未捕获标记错误“;,python,selenium,selenium-chromedriver,Python,Selenium,Selenium Chromedriver,在Windows 7、Python 3.6.4、Selenium 3.9.0和Chromedriver 2.43上运行代码时,代码在非headless模式下执行时不会出现问题。在无头模式下,在Anaconda提示符下执行,连续输出以下错误: 由于您在windows上运行,因此在使用headless时需要添加--disable gpu参数。看 在您说正在使用的selenium版本3.9中,您还可以使用方便的方法set_headless(),该方法将为您添加--headless和--禁用gpu。在较
由于您在windows上运行,因此在使用headless时需要添加
--disable gpu
参数。看
在您说正在使用的selenium版本
3.9
中,您还可以使用方便的方法set_headless()
,该方法将为您添加--headless
和--禁用gpu
。在较新版本中,它是一个setteroptions.headless=True
尝试了chrome\u选项。添加\u参数(“--disable gpu”)
。同样的错误我猜是因为您有--disable extensions
选项。看起来有什么东西让chrome不高兴
from selenium import webdriver
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--headless")
chrome_options.add_argument('--user-agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"')
chrome_options.add_argument("--window-size=1920x1080")
chrome_options.add_argument("--disable-extensions")
driver = webdriver.Chrome(chrome_options=chrome_options)
driver.get('https://www.mycarinfo.com.my/Valuation/SearchVehicle?version=free')