爬虫-Chrome-问题1

2018-06-18 03:12:04来源:未知 阅读 ()

新老客户大回馈,云服务器低至5折

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()

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:Flask入门flask-script 蓝本 钩子函数(三)

下一篇:第六篇:Python函数进阶篇