爬虫-Chrome-问题1

Posted Lucas_Yu

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了爬虫-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()

以上是关于爬虫-Chrome-问题1的主要内容,如果未能解决你的问题,请参考以下文章