ChromeDriver设置headless参数就会出现未知错误,,非得设置参数--no-sandbox;原因待查,找了好久,供参考.
cited from stackoverflow
I was having the same problem on centos7.1 because I was the root user, and it was resolved after adding the code chrome_options.add_argument(‘--no-sandbox‘)
here is my code
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument(‘--no-sandbox‘)
chrome_options.add_argument(‘--headless‘)
driver = webdriver.Chrome(chrome_options=chrome_options)
driver.get(‘https://www.google.com/‘)
print driver.current_url
driver.quit()
原文地址:https://www.cnblogs.com/wdmx/p/9111873.html
时间: 2024-11-03 23:13:05