Using selenium+chromedriver crawler under Linux to report an error

mistake:

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)

Solution:

Start the Display before start the Chrome. 

First execute the following two installation commands (take ubuntu as an example):

 

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

Then add the following code:

 

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

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325650119&siteId=291194637