Linux下利用selenium+chromedriver爬虫报错

错误:

selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally (Driver info: chromedriver=2.34.522913 (36222509aa6e819815938cbf2709b4849735537c),platform=Linux 4.10.0-42-generic x86_64)

解决办法:

Start the Display before start the Chrome. 

先执行一下两句安装命令(以ubuntu为例):

[html]  view plain  copy
 
  1. pip install pyvirtualdisplay  
  2. sudo apt-get install xvfb  

然后添加如下代码:

[python]  view plain  copy
 
  1. from pyvirtualdisplay import Display  
  2. display = Display(visible=0, size=(800, 800))    
  3. display.start()  
  4. driver = webdriver.Chrome()  

猜你喜欢

转载自www.cnblogs.com/z-x-y/p/9004493.html