爬虫-Chrome-问题1

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()
posted @ 2018-05-30 16:51  Lucas_Yu  阅读(247)  评论(0编辑  收藏  举报